mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-11 13:45:25 +00:00
COMMON: Added auxiliary methods for punycode
This commit is contained in:
parent
56f7af8d2e
commit
a655cff203
@ -73,7 +73,7 @@ static uint32_t adapt_bias(uint32_t delta, unsigned n_points, int is_first) {
|
||||
static char encode_digit(int c) {
|
||||
assert(c >= 0 && c <= BASE - TMIN);
|
||||
if (c > 25) {
|
||||
return c + 22; /* '0'..'9' */
|
||||
return c + 26; /* '0'..'9' */
|
||||
} else {
|
||||
return c + 'a'; /* 'a'..'z' */
|
||||
}
|
||||
@ -191,6 +191,20 @@ fail:
|
||||
return si;
|
||||
}
|
||||
|
||||
bool punycode_hasprefix(const String src) {
|
||||
return src.hasPrefix("xn--");
|
||||
}
|
||||
|
||||
bool punycode_needEncode(const String src) {
|
||||
for (int si = 0; si < src.size(); si++) {
|
||||
if (src[si] & 0x80 || src[si] < 0x20) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
String punycode_decode(const String src1) {
|
||||
if (!src1.hasPrefix("xn--"))
|
||||
return src1;
|
||||
|
@ -63,6 +63,9 @@ String punycode_decode(const String src);
|
||||
*/
|
||||
String punycode_decodefilename(const String src1);
|
||||
|
||||
bool punycode_hasprefix(const String src);
|
||||
|
||||
bool punycode_needEncode(const String src);
|
||||
|
||||
} // end of namespace Common
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user