Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

Decoding CJK characters to unicode in Tcl


I know how to display Chinese characters in Tk, such as wm title,
button names, etc. For example,
% wm title . "\u592a\u9177"
% button .f -text "\u592a\u9177" -font {-family MingLiU -size 16 -
weight bold}
I'll see "? ?" (very cool).
My problem is how to decode a CJK character to its unicode in Tcl
given the CJK unicode table:
 0 1 2 3 4 5 6 7 8 9 a b c d e f
4E00 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
4E10 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
4E20 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
...
In tkcon, I can set a Chinese charter, i.e.
% set x ?;
tkcon can display $x.
When I use "read" to load the table, tkcon cannot display it in
Chinese (I got ??? for Chinese characters).
If I combine $x with other string, i.e.
% set y "abc ?".
% I'll get no match, 0 when I try:
% string math $x $y.
Any thought? Thanks in advance!
Tcl natively uses Unicode for (almost) all strings.
Does this example from an interactive wish help?

proc u2x str {
   set res {}
   foreach c [split $str ""] {
       scan $c %c i
       append res [expr {$i>127? "\\u[format %04.4x $i]" : $c}]
   }
   set res

}

166 % u2x "? ? - very cool"
\u592a \u9177 - very cool
On 14 mrt, 18:25, jhe@gmail.com wrote:

What if you try to match "*?"to $y:

% string match $x $y
1

- this works for me.

[string match] tries to match the whole string, but to do that the
pattern
usually requires a wildcard (* or ?)

The problem with the display of the characters may be due to the lack
of the
proper Chinese fonts?

Regards,

Arjen

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc