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

Merge pull request #35 from subramanivmk/beef32

Added StartsWith(char32) & EndsWith(char32).
This commit is contained in:
Brian Fiete 2020-01-24 05:43:51 -08:00 committed by GitHub
commit 12ab5a13f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1723,6 +1723,26 @@ namespace System
return Ptr[mLength - 1] == c;
}
public bool EndsWith(char32 c)
{
int encodedLen = UTF8.GetEncodedLength(c);
char8* ptr = Ptr;
if (mLength == 0)
return false;
let (c32, _) = UTF8.Decode(ptr + mLength - 1 * encodedLen, encodedLen);
return c32 == c;
}
public bool StartsWith(char32 c)
{
int encodedLen = UTF8.GetEncodedLength(c);
char8* ptr = Ptr;
if (mLength == 0)
return false;
let (c32, _) = UTF8.Decode(ptr, encodedLen);
return c32 == c;
}
public void ReplaceLargerHelper(String find, String replace)
{
List<int> replaceEntries = scope List<int>(8192);
@ -3083,4 +3103,4 @@ namespace System
}
}
#endif
}
}