mirror of
https://github.com/Ryujinx/SDL2-CS.git
synced 2025-02-02 05:21:01 +00:00
stackalloc for UTF8_ToManaged
This commit is contained in:
parent
a16e9951f7
commit
f26b55e8be
|
@ -89,9 +89,10 @@ namespace SDL2
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
/* Old C# requires an extra memcpy, bleh! */
|
/* Old C# requires an extra memcpy, bleh! */
|
||||||
byte[] bytes = new byte[ptr - (byte*) s];
|
int len = (int) (ptr - (byte*) s);
|
||||||
Marshal.Copy(s, bytes, 0, bytes.Length);
|
char* chars = stackalloc char[len];
|
||||||
string result = System.Text.Encoding.UTF8.GetString(bytes);
|
System.Text.Encoding.UTF8.GetChars((byte*) s, len, chars, len);
|
||||||
|
string result = new string(chars);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Some SDL functions will malloc, we have to free! */
|
/* Some SDL functions will malloc, we have to free! */
|
||||||
|
|
Loading…
Reference in a new issue