diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-08-31 10:18:31 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-08-31 10:18:31 (GMT) |
commit | 573f9fd80810dede88587f8ec61fb5cbb4a100b8 (patch) | |
tree | 12b8693432cf7df9939fe220010831b9e4e2e251 /generic/tclEncoding.c | |
parent | 52eb2299f3995e1837bfa3bf899dba688a0db1dc (diff) | |
download | tcl-573f9fd80810dede88587f8ec61fb5cbb4a100b8.zip tcl-573f9fd80810dede88587f8ec61fb5cbb4a100b8.tar.gz tcl-573f9fd80810dede88587f8ec61fb5cbb4a100b8.tar.bz2 |
Some Unicode encoding fixes, only having effect if TCL_UTF_MAX > 4. Backported from androwish
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r-- | generic/tclEncoding.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index a7ef199..4ae017d 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2525,22 +2525,35 @@ UtfToUnicodeProc( if (dst > dstEnd) { result = TCL_CONVERT_NOSPACE; break; - } + } src += TclUtfToUniChar(src, &ch); /* * Need to handle this in a way that won't cause misalignment by * casting dst to a Tcl_UniChar. [Bug 1122671] - * XXX: This hard-codes the assumed size of Tcl_UniChar as 2. */ #ifdef WORDS_BIGENDIAN +#if TCL_UTF_MAX > 4 + *dst++ = (ch >> 24); + *dst++ = ((ch >> 16) & 0xFF); + *dst++ = ((ch >> 8) & 0xFF); + *dst++ = (ch & 0xFF); +#else *dst++ = (ch >> 8); *dst++ = (ch & 0xFF); +#endif +#else +#if TCL_UTF_MAX > 4 + *dst++ = (ch & 0xFF); + *dst++ = ((ch >> 8) & 0xFF); + *dst++ = ((ch >> 16) & 0xFF); + *dst++ = (ch >> 24); #else *dst++ = (ch & 0xFF); *dst++ = (ch >> 8); #endif +#endif } *srcReadPtr = src - srcStart; *dstWrotePtr = dst - dstStart; |