mirror of https://github.com/ppy/SDL3-CS.git
Remove unnecessary `UTF8GetBytes()` helper
This commit is contained in:
parent
72a002ead0
commit
8e0066d7f7
|
|
@ -14,19 +14,6 @@ namespace SDL3.Tests
|
|||
{
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
unsafe
|
||||
{
|
||||
// Encoding.UTF8.GetBytes can churn out null pointers and doesn't guarantee null termination
|
||||
fixed (byte* badPointer = Encoding.UTF8.GetBytes(""))
|
||||
Debug.Assert(badPointer == null);
|
||||
|
||||
fixed (byte* pointer = UTF8GetBytes(""))
|
||||
{
|
||||
Debug.Assert(pointer != null);
|
||||
Debug.Assert(pointer[0] == '\0');
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, "null byte \0 in string"u8);
|
||||
Debug.Assert(SDL_GetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4) == "null byte ");
|
||||
|
||||
|
|
|
|||
|
|
@ -27,17 +27,5 @@ namespace SDL
|
|||
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UTF8 encodes a managed <c>string</c> to a <c>byte</c> array suitable for use in <c>ReadOnlySpan<byte></c> parameters of SDL functions.
|
||||
/// </summary>
|
||||
/// <param name="s">The <c>string</c> to encode.</param>
|
||||
/// <returns>A null-terminated byte array.</returns>
|
||||
public static byte[] UTF8GetBytes(string s)
|
||||
{
|
||||
byte[] array = Encoding.UTF8.GetBytes(s + '\0');
|
||||
Debug.Assert(array[^1] == '\0');
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue