Support encoding UTF-8 characters
There's no loss doing it so, as FF = 255 and the upper half of the unsigned char range is exactly where we feel at home with UTF-8.
This commit is contained in:
parent
5ecd11fa3d
commit
29d53f65b7
1 changed files with 2 additions and 2 deletions
4
quark.c
4
quark.c
|
@ -172,7 +172,7 @@ decode(char src[PATH_MAX], char dest[PATH_MAX])
|
|||
if (*s == '+') {
|
||||
dest[i] = ' ';
|
||||
} else if (*s == '%' && (sscanf(s + 1, "%2hhx", &n) == 1)) {
|
||||
dest[i] = (char)(n & 255);
|
||||
dest[i] = n;
|
||||
s += 2;
|
||||
} else {
|
||||
dest[i] = *s;
|
||||
|
@ -191,7 +191,7 @@ encode(char src[PATH_MAX], char dest[PATH_MAX])
|
|||
|
||||
for (s = src, i = 0; *s; s++) {
|
||||
if (isalnum(*s) || *s == '~' || *s == '-' || *s == '.' ||
|
||||
*s == '_') {
|
||||
*s == '_' || *s > 127) {
|
||||
i += snprintf(dest + i, PATH_MAX - i, "%%%02X", *s);
|
||||
} else {
|
||||
dest[i] = *s;
|
||||
|
|
Loading…
Reference in a new issue