Skip to content
Tcl Source Code History Of Ticket 840577ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 840577ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 840577ffffffffffffffffffffffffffffffffff

  1. Ticket change [bcfb26dc88] (rid 101834) by aniixx on 2003-11-12 09:00:29:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. 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.
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "aniixx"
    9. subsystem initialized to: "None"
    10. title initialized to: "Problem in reading nonascii character."
    11. type initialized to: "Bug"
  2. Ticket change [5c9047a415] (rid 115326) by dkf on 2003-11-12 23:09:04:

    1. assignee changed to: "dkf"
    2. closedate changed to: "2003-11-12T16:09:04"
    3. closer changed to: "dkf"
    4. 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.
      
      
    5. login: "dkf"
    6. mimetype: "text/plain"
    7. priority changed to: "1 Zero"
    8. resolution changed to: "Invalid"
    9. status changed to: "Closed"
    10. subsystem changed to: "44. UTF-8 Strings"
    11. username: "dkf"