1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Merge pull request #1629 from disarray2077/fix_toscoped

Also use `c_wchar` in `StringView.ToScopedNativeWChar`
This commit is contained in:
Brian Fiete 2022-07-06 06:34:24 -07:00 committed by GitHub
commit 429cde7cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}