We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9a66b87 commit fd4658bCopy full SHA for fd4658b
src/python.ts
@@ -495,10 +495,12 @@ export class PyObject {
495
case "symbol":
496
case "string": {
497
const str = String(v);
498
+ const encoder = new TextEncoder();
499
+ const u8 = encoder.encode(str);
500
return new PyObject(
501
py.PyUnicode_DecodeUTF8(
- cstr(str),
- str.length,
502
+ u8,
503
+ u8.byteLength,
504
null,
505
),
506
);
test/test.ts
@@ -35,6 +35,9 @@ Deno.test("types", async (t) => {
35
await t.step("str", () => {
36
const value = python.str("hello");
37
assertEquals(value.valueOf(), "hello");
38
+
39
+ const unicode = python.str("'中文'");
40
+ assertEquals(unicode.valueOf(), "'中文'");
41
});
42
43
await t.step("list", () => {
0 commit comments