Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ccd4521

Browse files
committed
Match PyUnicode_AsUnicode signature in UCS2/UCS4
1 parent e487076 commit ccd4521

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/runtime/runtime.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ internal unsafe static extern int
15721572

15731573
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
15741574
ExactSpelling = true, CharSet = CharSet.Unicode)]
1575-
internal unsafe static extern char*
1575+
internal unsafe static extern IntPtr
15761576
PyUnicode_AsUnicode(IntPtr ob);
15771577

15781578
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
@@ -1613,7 +1613,7 @@ internal unsafe static extern int
16131613
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
16141614
EntryPoint = "PyUnicodeUCS2_AsUnicode",
16151615
ExactSpelling = true)]
1616-
internal unsafe static extern char*
1616+
internal unsafe static extern IntPtr
16171617
PyUnicode_AsUnicode(IntPtr ob);
16181618

16191619
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
@@ -1749,9 +1749,9 @@ internal unsafe static string GetManagedString(IntPtr op)
17491749
Marshal.Copy(p, buffer, 0, size);
17501750
return Encoding.UTF32.GetString(buffer, 0, size);
17511751
#elif UCS2
1752-
char* p = Runtime.PyUnicode_AsUnicode(op);
1753-
int size = Runtime.PyUnicode_GetSize(op);
1754-
return new String(p, 0, size);
1752+
IntPtr p = Runtime.PyUnicode_AsUnicode(op);
1753+
int length = Runtime.PyUnicode_GetSize(op);
1754+
return Marshal.PtrToStringUni(p, length);
17551755
#endif
17561756
}
17571757

0 commit comments

Comments
 (0)