From: Nguyen Thai Ngoc Duy Date: Tue, 21 Feb 2012 14:53:30 GMT Subject: Re: [PATCH 2/4] Do attempt pretty print in ASCII-incompatible encodings Message-ID: In-Reply-To: <1329834292-2511-2-git-send-email-pclouds@gmail.com> 2012/2/21 Nguyễn Thái Ngọc Duy : > @@ -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