COMMON: Fix punycode encoding
This commit is contained in:
parent
2fce9db178
commit
e6429a1213
1 changed files with 7 additions and 4 deletions
|
@ -142,8 +142,10 @@ String punycode_encode(String src) {
|
||||||
int b = h;
|
int b = h;
|
||||||
|
|
||||||
/* Write out delimiter if any basic code points were processed. */
|
/* Write out delimiter if any basic code points were processed. */
|
||||||
if (!dst.empty()) {
|
if (h != srclen) {
|
||||||
dst += '-';
|
dst = String::format("xn--%s-", dst.c_str());
|
||||||
|
} else {
|
||||||
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
int n = INITIAL_N;
|
int n = INITIAL_N;
|
||||||
|
@ -303,7 +305,8 @@ String punycode_encodefilename(const String src) {
|
||||||
dst += '\x79';
|
dst += '\x79';
|
||||||
// [\x00-\x1f\/":]
|
// [\x00-\x1f\/":]
|
||||||
} else if (src[i] == '/' || src[i] == '"' || src[i] == ':' || (byte)src[i] < 0x20) {
|
} else if (src[i] == '/' || src[i] == '"' || src[i] == ':' || (byte)src[i] < 0x20) {
|
||||||
dst += src[i] + 0x80;
|
dst += '\x81';
|
||||||
|
dst += (byte)src[i] + 0x80;
|
||||||
} else {
|
} else {
|
||||||
dst += src[i];
|
dst += src[i];
|
||||||
}
|
}
|
||||||
|
@ -340,7 +343,7 @@ String punycode_decodefilename(const String src1) {
|
||||||
if (src[i] == 0x79)
|
if (src[i] == 0x79)
|
||||||
dst += 0x81;
|
dst += 0x81;
|
||||||
else
|
else
|
||||||
dst += src[i] - 0x80;
|
dst += (byte)src[i] - 0x80;
|
||||||
} else {
|
} else {
|
||||||
dst += src[i];
|
dst += src[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue