[git commit branch/0.9.33] wchar: Fix BOM emitting in iconv_open()

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Thu Apr 26 20:37:22 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=0e2870e3d21986e707e90c88e1aea3bdf962713a
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/0.9.33

Fix incorrect output of BOM when converting charactersets by name. Only
affective when iconv/locale enabled.

Signed-off-by: Ed Wildgoose <lists at wildgooses.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/misc/wchar/wchar.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index ab6c617..412c557 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;


More information about the uClibc-cvs mailing list