Artifacts Associated With Ticket 840577ffffffffff
Ticket change [bcfb26dc88] (rid 101834) by aniixx on 2003-11-12 09:00:29:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi, We have Tcl integrated with C++ application. The user commands from tclsh are mapped to the C++ functions & handled in the C++ application. We are facing some problem while reading nonascii characters from a file. I have given some commands that I have tried for your reference below. Check the octal dumps to verify the contents of the file. While reading or storing it in a Tcl variable, Tcl does some kind of encoding (possibly UTF-8 encoding). But puts strips the extra character off or decodes it. Any idea if it's a Tcl bug? We pass this variable to C++ application & on the other end we get wrong output (extra character). Thanx, Aniket $ echo "abc\200xyz" > /tmp/wipro $ od -xC /tmp/wipro 0000000 6162 6380 7879 7a0a a b c 200 x y z \n 0000010 $ xmytclsh > set fd [ open /tmp/wipro r] > set data [ read -nonewline $fd ] > puts $data abcxyz > echo $data abcÂxyz > set fd [ open /tmp/wipro r] > set data [ read $fd ] > puts $data abcxyz > echo $data abcÂxyz > set fdw [ open /tmp/wipro_write w] > puts $fdw $data > close $fdw > set data "abc\0200xyz" > echo $data abc0xyz > puts $data abc0xyz > exit $ od -xC /tmp/wipro_write 0000000 6162 6380 7879 7a0a 0a00 a b c 200 x y z \n \n 0000011 Note: Octal dump if abcÂxyz is passed to C++ appln & received at output is 0000000 6162 63c2 8078 797a a b c  200 x y z 0000010 You can surely see additional character  here. - foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "aniixx"
- subsystem initialized to: "None"
- title initialized to: "Problem in reading nonascii character."
- type initialized to: "Bug"
Ticket change [5c9047a415] (rid 115326) by dkf on 2003-11-12 23:09:04:
- assignee changed to: "dkf"
- closedate changed to: "2003-11-12T16:09:04"
- closer changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 You're in a twist over encodings it seems. What character is that \200 meant to be? What is your system encoding? (Use [encoding system] to find that out.) What platform are you on? Hmm. Guessing that your system encoding is UTF-8 (which might be the case on MacOSX and might be true elsewhere too) you're going to have to use [fconfigure] to help out, perhaps like this: fconfigure $fd -encoding iso8859-1 Another alternative is to put the channel into binary mode: fconfigure $fd -translation binary I'd need to know your situation in detail to tell you which is best.
- login: "dkf"
- mimetype: "text/plain"
- priority changed to: "1 Zero"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- subsystem changed to: "44. UTF-8 Strings"
- username: "dkf"