When a null C# string is passed to UTF8_ToNative(), return a null pointer instead of an empty C string.
This commit is contained in:
parent
ed4838b75d
commit
77cffe2f92
11
src/SDL2.cs
11
src/SDL2.cs
@ -45,8 +45,15 @@ namespace SDL2
|
|||||||
|
|
||||||
internal static byte[] UTF8_ToNative(string s)
|
internal static byte[] UTF8_ToNative(string s)
|
||||||
{
|
{
|
||||||
// Add a null terminator. That's kind of it... :/
|
if (s != null)
|
||||||
return System.Text.Encoding.UTF8.GetBytes(s + '\0');
|
{
|
||||||
|
// Add a null terminator. That's kind of it... :/
|
||||||
|
return System.Text.Encoding.UTF8.GetBytes(s + '\0');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static unsafe string UTF8_ToManaged(IntPtr s, bool freePtr = false)
|
internal static unsafe string UTF8_ToManaged(IntPtr s, bool freePtr = false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user