diff options
author | nijtmans@users.sourceforge.net <jan.nijtmans> | 2016-09-26 11:54:46 (GMT) |
---|---|---|
committer | nijtmans@users.sourceforge.net <jan.nijtmans> | 2016-09-26 11:54:46 (GMT) |
commit | d7bff6f0e144dbfedeaab9a286b21467556e0bcf (patch) | |
tree | 4fc677a1c37fe3d482cb9e1d048ada2e1c048a23 /generic | |
parent | 0bac5a60215932ab3237dfc976e482065e204ab6 (diff) | |
parent | 660fab34b7a20362f7d78d6e4dc83f4824804fcc (diff) | |
download | tk-d7bff6f0e144dbfedeaab9a286b21467556e0bcf.zip tk-d7bff6f0e144dbfedeaab9a286b21467556e0bcf.tar.gz tk-d7bff6f0e144dbfedeaab9a286b21467556e0bcf.tar.bz2 |
merge core-8-6-branch
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkUtil.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 7ff0b9e..e686826 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1200,8 +1200,8 @@ TkSendVirtualEvent( * TkUtfToUniChar -- * * Almost the same as Tcl_UtfToUniChar but using int instead of Tcl_UniChar. - * This function is capable of collapsing a upper/lower pair to a single - * unicode character. So, up to 6 bytes (two UTF-8 characters) might be read. + * This function is capable of collapsing a upper/lower surrogate pair to a + * single unicode character. So, up to 6 bytes might be consumed. * * Results: * *chPtr is filled with the Tcl_UniChar, and the return value is the @@ -1224,11 +1224,11 @@ TkUtfToUniChar( int len = Tcl_UtfToUniChar(src, &uniChar); if ((uniChar & 0xfc00) == 0xd800) { Tcl_UniChar high = uniChar; - /* This can only happen when Tcl is compiled with TCL_UTF_MAX=4, - * or when a high surrogate character is detected */ + /* This can only happen if Tcl is compiled with TCL_UTF_MAX=4, + * or when a high surrogate character is detected in UTF-8 form */ int len2 = Tcl_UtfToUniChar(src+len, &uniChar); if ((uniChar & 0xfc00) == 0xdc00) { - *chPtr = ((high & 0x3ff) << 10) | (uniChar & 0x3ff) | 0x10000; + *chPtr = (((high & 0x3ff) << 10) | (uniChar & 0x3ff)) + 0x10000; len += len2; } else { *chPtr = high; @@ -1245,7 +1245,7 @@ TkUtfToUniChar( * TkUniCharToUtf -- * * Almost the same as Tcl_UniCharToUtf but producing surrogates if - * TCL_UTF_MAX==3. + * TCL_UTF_MAX==3. So, up to 6 bytes might be produced. * * Results: * *buf is filled with the UTF-8 string, and the return value is the @@ -1260,7 +1260,7 @@ TkUtfToUniChar( int TkUniCharToUtf(int ch, char *buf) { int size = Tcl_UniCharToUtf(ch, buf); - if ((ch > 0xffff) && (size < 4)) { + if ((ch > 0xffff) && (ch <= 0x10ffff) && (size < 4)) { /* Hey, this is wrong, we must be running TCL_UTF_MAX==3 * The best thing we can do is spit out 2 surrogates */ ch -= 0x10000; |