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 da051a9 commit 1b6c6c0Copy full SHA for 1b6c6c0
src/runtime/runtime.cs
@@ -1646,11 +1646,12 @@ internal static string GetManagedString(IntPtr op)
1646
if (type == PyUnicodeType)
1647
{
1648
using var p = PyUnicode_AsUTF16String(new BorrowedReference(op));
1649
- int length = (int)PyUnicode_GetSize(op);
1650
- char* codePoints = (char*)PyBytes_AsString(p.DangerousGetAddress());
+ var bytesPtr = p.DangerousGetAddress();
+ int bytesLength = (int)Runtime.PyBytes_Size(bytesPtr);
1651
+ char* codePoints = (char*)PyBytes_AsString(bytesPtr);
1652
return new string(codePoints,
1653
startIndex: 1, // skip BOM
- length: length);
1654
+ length: bytesLength/2-1); // utf16 - BOM
1655
}
1656
1657
return null;
0 commit comments