UTF-8 encode and decode: Difference between revisions
Content deleted Content added
another take in Tcl |
|||
Line 409: | Line 409: | ||
scan $codepoint %llx cp |
scan $codepoint %llx cp |
||
if {$cp < 0x10000} { |
if {$cp < 0x10000} { |
||
set str [ |
set str [subst \\u$codepoint] ;# substitute per Tcl backslash rule |
||
set str [subst $str] ;# substitute per Tcl rules |
|||
set bytes [encoding convertto utf-8 $str] ;# encode |
set bytes [encoding convertto utf-8 $str] ;# encode |
||
} else { ;# codepoints beyond the BMP need manual approach |
} else { ;# codepoints beyond the BMP need manual approach |