mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Add Startswith & Endswith char32 overload for StringView
This commit is contained in:
parent
e5f92fb21b
commit
4061d4b58e
1 changed files with 22 additions and 0 deletions
|
@ -3137,6 +3137,15 @@ namespace System
|
||||||
return Ptr[0] == c;
|
return Ptr[0] == c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool StartsWith(char32 c)
|
||||||
|
{
|
||||||
|
if (c < '\x80')
|
||||||
|
return StartsWith((char8)c);
|
||||||
|
if (mLength == 0)
|
||||||
|
return false;
|
||||||
|
return UTF8.Decode(Ptr, mLength).c == c;
|
||||||
|
}
|
||||||
|
|
||||||
public bool EndsWith(char8 c)
|
public bool EndsWith(char8 c)
|
||||||
{
|
{
|
||||||
if (mLength == 0)
|
if (mLength == 0)
|
||||||
|
@ -3144,6 +3153,19 @@ namespace System
|
||||||
return Ptr[mLength - 1] == c;
|
return Ptr[mLength - 1] == c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool EndsWith(char32 c)
|
||||||
|
{
|
||||||
|
if (c < '\x80')
|
||||||
|
return EndsWith((char8)c);
|
||||||
|
if (mLength == 0)
|
||||||
|
return false;
|
||||||
|
char8* ptr = Ptr;
|
||||||
|
int idx = mLength - 1;
|
||||||
|
while ((idx > 0) && ((uint8)ptr[idx] & 0xC0 == 0x80))
|
||||||
|
idx--;
|
||||||
|
return UTF8.Decode(ptr + idx, mLength - idx).c == c;
|
||||||
|
}
|
||||||
|
|
||||||
public void QuoteString(String outString)
|
public void QuoteString(String outString)
|
||||||
{
|
{
|
||||||
String.QuoteString(Ptr, Length, outString);
|
String.QuoteString(Ptr, Length, outString);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue