mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 15:24:10 +02:00
Fixed UTF16/32 encoding issues regarding null termination
This commit is contained in:
parent
5fd9552331
commit
cf6ade5e45
4 changed files with 8 additions and 11 deletions
|
@ -2516,11 +2516,11 @@ namespace System
|
|||
c_wchar* buf;
|
||||
if (encodedLen < 128)
|
||||
{
|
||||
buf = scope:mixin c_wchar[encodedLen]* ( ? );
|
||||
buf = scope:mixin c_wchar[encodedLen+1]* ( ? );
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = new c_wchar[encodedLen]* ( ? );
|
||||
buf = new c_wchar[encodedLen+1]* ( ? );
|
||||
defer:mixin delete buf;
|
||||
}
|
||||
|
||||
|
@ -2528,6 +2528,7 @@ namespace System
|
|||
UTF16.Encode(this, (.)buf, encodedLen);
|
||||
else
|
||||
UTF32.Encode(this, (.)buf, encodedLen);
|
||||
buf[encodedLen] = 0;
|
||||
buf
|
||||
}
|
||||
|
||||
|
@ -3805,15 +3806,16 @@ namespace System
|
|||
char16* buf;
|
||||
if (encodedLen < 128)
|
||||
{
|
||||
buf = scope:mixin char16[encodedLen]* ( ? );
|
||||
buf = scope:mixin char16[encodedLen+1]* ( ? );
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = new char16[encodedLen]* ( ? );
|
||||
buf = new char16[encodedLen+1]* ( ? );
|
||||
defer:mixin delete buf;
|
||||
}
|
||||
|
||||
UTF16.Encode(this, buf, encodedLen);
|
||||
buf[encodedLen] = 0;
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue