Re: Handling escaped chars (using \ char) from a user
- From: Michael Schlenker <schlenk@xxxxxxxxxxxxxxxx>
- Date: Fri, 14 Jul 2006 23:46:30 +0200
Johnny Cybermyth schrieb:
I'm writing a plugin for a serial port program and need to supportTcl has a fine encoding subsystem for all kinds of non-ascii chars. If
sending non ASCII chars. I would like to allow the user to express
non-ASCII chars in a simple hex escape format: \01 \0D etc
So a sample string would be input as:
\01A01TEST\02
which would be interpreted as a string of these hex chars:
01 41 30 31 54 45 53 54 02
I'm new to TCL so any ideas on better ways to get this done is appreciated.
it fits into the basic multilingual plane of unicode you can use it in Tcl.
There is already an escape mechanism for unicode characters like this:
\u20ac (euro symbol)
you can also use other escapes like \0x but the \u escapes are the most
useful.
See for some examples:
http://wiki.tcl.tk/encoding
http://wiki.tcl.tk/515
http://wiki.tcl.tk/binary
If you want to process arbitraty binary data look at the [binary] commands.
If you tell us a bit more of what you have to do, we can probably help
you to find a good solution.
Michael
.
- References:
- Handling escaped chars (using \ char) from a user
- From: Johnny Cybermyth
- Handling escaped chars (using \ char) from a user
- Prev by Date: Handling escaped chars (using \ char) from a user
- Next by Date: Nasty problem with background fcopy from socket to stdout
- Previous by thread: Handling escaped chars (using \ char) from a user
- Next by thread: Nasty problem with background fcopy from socket to stdout
- Index(es):
Relevant Pages
|