Patch: Fix emitting BOM in wchar.c

Ed W lists at wildgooses.com
Tue Apr 17 11:13:32 UTC 2012


Hi, this is a resend of a patch I already submitted.  It resolves a 
logical problem in the current iconv handling where we are incorrectly 
emitting BOM marks.  It doesn't change functionality, just changes so 
that we only emit BOM marks under the correct circumstances

Grateful if this could be applied

Thanks


Ed W

---


Fix a problem with wide character handling. Currently
it is incorrectly emitting byte order marks (not entirely correct ones
either) for random choice of characterset names.  The current code uses
the same function to find codesets as it code for charactersets - the
subsequent logic didn't handle characterset name as input (rather than
code name)

Commit:

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)





-------------- next part --------------
--- libc/misc/wchar/wchar.c.orig	2011-10-30 20:00:01.000000000 +0000
+++ libc/misc/wchar/wchar.c	2011-10-30 20:02:55.000000000 +0000
@@ -1308,9 +1308,9 @@
 		&& ((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;

-------------- next part --------------
_______________________________________________
uClibc mailing list
uClibc at uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc


More information about the uClibc mailing list