Thread (10 messages) flat view 10 messages, 3 authors, 2016-06-15

Re: [PATCH 2/4] Do attempt pretty print in ASCII-incompatible encodings

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:53:07

2012/2/21 Nguyễn Thái Ngọc Duy [off-list ref]:
quoted hunk ↗ jump to hunk
@@ -482,3 +482,18 @@ char *reencode_string(const char *in, const char *out_encoding, const char *in_e
       return out;
 }
 #endif
+
+int ascii_superset_encoding(const char *encoding)
+{
+       const char *sample = " !\"#$%&'()*+,-./0123456789:;<=>?@"
+               "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"
+               "abcdefghijklmnopqrstuvwxyz{|}~\n";
+       char *output;
+       int ret;
+       if (!encoding)
+               return 1;
+       output = reencode_string(sample, encoding, "US-ASCII");
+       ret = !output || !strcmp(sample, output);
+       free(output);
+       return ret;
+}
Side note about this function, which was written to ban all
ascii-incompatible charsets from entering commit objects. The idea of
mixing charsets in the same buffer without clear boundary does not
sound healthy. Plus, ident.c will silently drop '\n', '<' and '>' in
author/committer. If a hypothetical charset happens to place a letter
in those, um.. code points?, the letter will be dropped. But meh..
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help