about summary refs log tree commit diff
path: root/src/locale/iconv.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-05-21 17:01:23 -0400
committerRich Felker <dalias@aerifal.cx>2015-05-21 17:01:23 -0400
commit39b8ce66f2ed9c17427ec3a48be9bda29b93b9d7 (patch)
tree97dbd9cf6cea6ea9b3cd0670a0e9bafd4b035267 /src/locale/iconv.c
parentc648cefb27984db60474ec1747cbfde83c2856d0 (diff)
downloadmusl-39b8ce66f2ed9c17427ec3a48be9bda29b93b9d7.tar.gz
musl-39b8ce66f2ed9c17427ec3a48be9bda29b93b9d7.tar.xz
musl-39b8ce66f2ed9c17427ec3a48be9bda29b93b9d7.zip
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.
Diffstat (limited to 'src/locale/iconv.c')
-rw-r--r--src/locale/iconv.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
index a0b02320..3c20c898 100644
--- a/src/locale/iconv.c
+++ b/src/locale/iconv.c
@@ -35,7 +35,7 @@
  * 3. Character table (size determined by field 2). */
 
 static const unsigned char charmaps[] =
-"utf8\0\0\310"
+"utf8\0char\0\0\310"
 "wchart\0\0\306"
 "ucs2\0ucs2be\0\0\304"
 "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)
 {
 	const unsigned char *s;
+	if (!*(char *)name) name=charmaps; /* "utf8" */
 	for (s=charmaps; *s; ) {
 		if (!fuzzycmp(name, s)) {
 			for (; *s; s+=strlen((void *)s)+1);