summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd W <lists@wildgooses.com>2012-04-17 12:13:32 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-04-17 22:13:34 +0200
commitab3c5d5b0d774f8cb1bef4bd1aff96c3bbe2da4b (patch)
tree7e8a1d2ee6aa348b2e7ca35dce76cbdf8f836c5b
parenta2cc7378449b37ecc56d6f24ad54a00aada8cfb9 (diff)
wchar: Fix BOM emitting in iconv_open()
Fix incorrect output of BOM when converting charactersets by name. Only affective when iconv/locale enabled. Signed-off-by: Ed Wildgoose <lists@wildgooses.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r--libc/misc/wchar/wchar.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index ab6c617ed..412c557eb 100644
--- a/libc/misc/wchar/wchar.c
+++ b/libc/misc/wchar/wchar.c
@@ -1308,9 +1308,9 @@ iconv_t weak_function iconv_open(const char *tocode, const char *fromcode)
&& ((fromcodeset = find_codeset(fromcode)) != 0)) {
if ((px = malloc(sizeof(_UC_iconv_t))) != NULL) {
px->tocodeset = tocodeset;
- px->tobom0 = px->tobom = (tocodeset & 0x10) >> 4;
+ px->tobom0 = px->tobom = (tocodeset >= 0xe0) ? (tocodeset & 0x10) >> 4 : 0;
px->fromcodeset0 = px->fromcodeset = fromcodeset;
- px->frombom0 = px->frombom = (fromcodeset & 0x10) >> 4;
+ px->frombom0 = px->frombom = (fromcodeset >= 0xe0) ? (fromcodeset & 0x10) >> 4 : 0;
px->skip_invalid_input = px->tostate.__mask
= px->fromstate.__mask = 0;
return (iconv_t) px;