Browse Source

in iconv_open, accept "CHAR" and "" as aliases for "UTF-8"

while not a requirement, it's common convention in other iconv
implementations to accept "CHAR" as an alias for nl_langinfo(CODESET),
meaning the encoding used for char[] strings in the current locale,
and also "" as an alternate form. supporting this is not costly and
improves compatibility.
master
Rich Felker 11 years ago
parent
commit
39b8ce66f2
  1. 3
      src/locale/iconv.c

3
src/locale/iconv.c

@ -35,7 +35,7 @@
* 3. Character table (size determined by field 2). */ * 3. Character table (size determined by field 2). */
static const unsigned char charmaps[] = static const unsigned char charmaps[] =
"utf8\0\0\310" "utf8\0char\0\0\310"
"wchart\0\0\306" "wchart\0\0\306"
"ucs2\0ucs2be\0\0\304" "ucs2\0ucs2be\0\0\304"
"ucs2le\0\0\305" "ucs2le\0\0\305"
@ -90,6 +90,7 @@ static int fuzzycmp(const unsigned char *a, const unsigned char *b)
static size_t find_charmap(const void *name) static size_t find_charmap(const void *name)
{ {
const unsigned char *s; const unsigned char *s;
if (!*(char *)name) name=charmaps; /* "utf8" */
for (s=charmaps; *s; ) { for (s=charmaps; *s; ) {
if (!fuzzycmp(name, s)) { if (!fuzzycmp(name, s)) {
for (; *s; s+=strlen((void *)s)+1); for (; *s; s+=strlen((void *)s)+1);

Loading…
Cancel
Save