diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-22 21:28:16 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-22 21:28:16 (GMT) |
commit | 0a2c1e30b152c1fcbd3180aadaf6b27039f07421 (patch) | |
tree | ed2ffe7437994ef55aa62151723fc6c9a27f50fa /generic/tclUtf.c | |
parent | d6deb4d6d99f3ea3b0f50de0fdf0f06903f41956 (diff) | |
download | tcl-0a2c1e30b152c1fcbd3180aadaf6b27039f07421.zip tcl-0a2c1e30b152c1fcbd3180aadaf6b27039f07421.tar.gz tcl-0a2c1e30b152c1fcbd3180aadaf6b27039f07421.tar.bz2 |
Split more "string" functions. New helper function TclUniCharToUCS4(), not used yet but that's the next step.
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r-- | generic/tclUtf.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c index fd6ec1b..db2fc02 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -2634,6 +2634,20 @@ TclUtfToUCS4( /* Make use of the #undef Tcl_UtfToUniChar above, which already handles UCS4. */ return Tcl_UtfToUniChar(src, ucs4Ptr); } + +int +TclUniCharToUCS4( + const Tcl_UniChar *src, /* The Tcl_UniChar string. */ + int *ucs4Ptr) /* Filled with the UCS4 codepoint represented + * by the Tcl_UniChar string. */ +{ + if (((src[0] & 0xFC00) == 0xD800) && ((src[1] & 0xFC00) == 0xDC00)) { + *ucs4Ptr = (((src[0] & 0x3FF) << 10) | (src[01] & 0x3FF)) + 0x10000; + return 2; + } + *ucs4Ptr = src[0]; + return 1; +} #endif /* |