From 14b0af7f22068f9b4ab4b891f8fd93b956896942 Mon Sep 17 00:00:00 2001 From: disarray2077 <86157825+disarray2077@users.noreply.github.com> Date: Mon, 4 Jul 2022 23:37:46 -0300 Subject: [PATCH] Also use c_wchar in StringView.ToScopedNativeWChar --- BeefLibs/corlib/src/String.bf | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/BeefLibs/corlib/src/String.bf b/BeefLibs/corlib/src/String.bf index 4bc264e2..3425e7b4 100644 --- a/BeefLibs/corlib/src/String.bf +++ b/BeefLibs/corlib/src/String.bf @@ -4107,18 +4107,21 @@ namespace System public mixin ToScopedNativeWChar() { int encodedLen = UTF16.GetEncodedLen(this); - char16* buf; + c_wchar* buf; if (encodedLen < 128) { - buf = scope:mixin char16[encodedLen+1]* ( ? ); + buf = scope:mixin c_wchar[encodedLen+1]* ( ? ); } else { - buf = new char16[encodedLen+1]* ( ? ); + buf = new c_wchar[encodedLen+1]* ( ? ); defer:mixin delete buf; } - UTF16.Encode(this, buf, encodedLen); + if (sizeof(c_wchar) == 2) + UTF16.Encode(this, (.)buf, encodedLen); + else + UTF32.Encode(this, (.)buf, encodedLen); buf[encodedLen] = 0; buf }