Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit07f65c7

Browse files
committed
Copy potential BOM to the output of PyString_FromString
The documentation of the used `PyUnicode_DecodeUTF16` states that notpassing `*byteorder` or passing a 0 results in the first two bytes, ifthey are the BOM (U+FEFF, zero-width no-break space), to be interpretedand skipped, which is incorrect when we convert a known "non BOM"string, which all strings from C# are.
1 parent161a7e7 commit07f65c7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎src/runtime/Runtime.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,12 +1252,14 @@ internal static bool PyString_CheckExact(BorrowedReference ob)
12521252

12531253
internalstaticNewReferencePyString_FromString(stringvalue)
12541254
{
1255+
intbyteorder=BitConverter.IsLittleEndian?-1:1;
1256+
int*byteorderPtr=&byteorder;
12551257
fixed(char*ptr=value)
12561258
returnDelegates.PyUnicode_DecodeUTF16(
12571259
(IntPtr)ptr,
12581260
value.Length*sizeof(Char),
12591261
IntPtr.Zero,
1260-
IntPtr.Zero
1262+
(IntPtr)byteorderPtr
12611263
);
12621264
}
12631265

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp