[hackers] [quark] Support encoding UTF-8 characters || FRIGN
commit 29d53f65b70dd8f4ed2ae54ac17877dce29c8cf9
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Mon Sep 5 20:10:16 2016 +0200
Commit: FRIGN <dev_AT_frign.de>
CommitDate: Mon Sep 5 20:10:16 2016 +0200
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.
diff --git a/quark.c b/quark.c
index 2c03271..1faad5d 100644
--- a/quark.c
+++ b/quark.c
_AT_@ -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;
_AT_@ -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;
Received on Mon Sep 05 2016 - 20:12:19 CEST
This archive was generated by hypermail 2.3.0
: Mon Sep 05 2016 - 20:24:15 CEST