Closed spahnke closed 5 years ago
a cast to wchar_t* discards all characters after a zero byte
Not the cast discards it, but the String constructor without length parameter :)
EDIT: Ok, the comment in the code is right, just the PR description was slightly misleading.
Since C++ uses zero byte terminated strings, a cast to wchar_t* discards all characters after a zero byte when used directly to create a C# or V8 string. This is bad for strings containing a zero byte somewhere. We fix that by using a constructor overload taking the actual length of the string as parameter.
Example:
would arrive as
"a"
in C# without the fix and vice versa.