mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 15:24:10 +02:00
32-bit c_wchar improvements
This commit is contained in:
parent
a7075707fe
commit
a89e36248f
3 changed files with 185 additions and 9 deletions
|
@ -2436,29 +2436,43 @@ namespace System
|
|||
public mixin ToScopedNativeWChar()
|
||||
{
|
||||
int encodedLen = UTF16.GetEncodedLen(this);
|
||||
char16* buf;
|
||||
c_wchar* buf;
|
||||
if (encodedLen < 128)
|
||||
{
|
||||
buf = scope:mixin char16[encodedLen]* ( ? );
|
||||
buf = scope:mixin c_wchar[encodedLen]* ( ? );
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = new char16[encodedLen]* ( ? );
|
||||
buf = new c_wchar[encodedLen]* ( ? );
|
||||
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
|
||||
}
|
||||
|
||||
[Comptime(ConstEval=true)]
|
||||
public Span<c_wchar> ToConstNativeW()
|
||||
{
|
||||
int encodedLen = UTF16.GetEncodedLen(this);
|
||||
var buf = new char16[encodedLen + 1]* ( ? );
|
||||
UTF16.Encode(this, buf, encodedLen);
|
||||
buf[encodedLen] = 0;
|
||||
return .(buf, encodedLen + 1);
|
||||
if (sizeof(c_wchar) == 2)
|
||||
{
|
||||
int encodedLen = UTF16.GetEncodedLen(this);
|
||||
var buf = new char16[encodedLen + 1]* ( ? );
|
||||
UTF16.Encode(this, buf, encodedLen);
|
||||
buf[encodedLen] = 0;
|
||||
return .((.)buf, encodedLen + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int encodedLen = UTF32.GetEncodedLen(this);
|
||||
var buf = new char32[encodedLen + 1]* ( ? );
|
||||
UTF32.Encode(this, buf, encodedLen);
|
||||
buf[encodedLen] = 0;
|
||||
return .((.)buf, encodedLen + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Equals(char8* str1, char8* str2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue