mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: ToAscii optimized, ToUpperAscii, ToLowerAscii
git-svn-id: svn://ultimatepp.org/upp/trunk@12678 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b47bfa76ca
commit
ad7d8a5a3e
7 changed files with 202 additions and 8 deletions
|
|
@ -136,4 +136,44 @@ Vector<dword> ToUtf32(const wchar *s, int len)
|
|||
return r;
|
||||
}
|
||||
|
||||
String Utf8ToAscii(const String& src)
|
||||
{
|
||||
StringBuffer r(src.GetLength());
|
||||
const char *s = src.begin();
|
||||
const char *lim = src.end();
|
||||
|
||||
char *t = r;
|
||||
while(s < lim)
|
||||
*t++ = (byte)*s < 128 ? *s++ : ToAscii(FetchUtf8(s, lim));
|
||||
r.SetLength(int(t - ~r));
|
||||
return r;
|
||||
}
|
||||
|
||||
String Utf8ToUpperAscii(const String& src)
|
||||
{
|
||||
StringBuffer r(src.GetLength());
|
||||
const char *s = src.begin();
|
||||
const char *lim = src.end();
|
||||
|
||||
char *t = r;
|
||||
while(s < lim) {
|
||||
*t++ = (byte)*s <= 'Z' ? *s++ : ToUpperAscii(FetchUtf8(s, lim));
|
||||
}
|
||||
r.SetLength(int(t - ~r));
|
||||
return r;
|
||||
}
|
||||
|
||||
String Utf8ToLowerAscii(const String& src)
|
||||
{
|
||||
StringBuffer r(src.GetLength());
|
||||
const char *s = src.begin();
|
||||
const char *lim = src.end();
|
||||
|
||||
char *t = r;
|
||||
while(s < lim)
|
||||
*t++ = ToLowerAscii(FetchUtf8(s, lim));
|
||||
r.SetLength(int(t - ~r));
|
||||
return r;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue