Skip to content
Tcl Source Code History Of Ticket 768852ffffffffff
Login

History Of Ticket 768852ffffffffff

Artifacts Associated With Ticket 768852ffffffffff

  1. Ticket change [099c928425] (rid 113686) by nobody on 2003-07-10 02:55:47:

    1. assignee initialized to: "nijtmans"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      I expected that
          set bar [binary format a* $foo]
      would result in $foo == $bar,
      but for a chineese utf-8 value of $foo it does not.
      
      Please see attached test script.
      
    4. foundin initialized to: "obsolete: 8.4.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "44. UTF-8 Strings"
    10. title initialized to: "binary format a* $utf8_string"
    11. type initialized to: "RFE"
  2. Ticket change [1fbdebcac6] (rid 91200) by nobody on 2003-07-10 09:55:47:

    1. icomment:
      
      
      File Added - 55416: test.tcl
      
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"
  3. Add attachment "test.tcl" [c1c12bd1b2] (rid 111376) by nobody on 2003-07-10 09:55:47.

  4. Ticket change [d1c5563e03] (rid 113412) by dkf on 2003-07-10 15:10:30:

    1. assignee changed to: "dkf"
    2. icomment:
      Logged In: YES 
      user_id=79902
      
      This is really the same issue as Bug 735364; leaving both
      bugs open for now because I'm not yet quite sure what the
      fix ought to be (something with encodings, probably.)
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. username: "dkf"
  5. Ticket change [8649c603f7] (rid 131481) by dkf on 2003-07-10 21:29:57:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Hmm.  Converting to ASCII by adding unicode escapes (easier 
      to port to different test platforms!) gives this:
        set foo \u6211\u56fd
        set bar [binary format a* $foo]
        if { $foo != $bar } {
           puts "foo != bar"
        }
      Still not sure if those strings *should* be equal or not...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  6. Ticket change [c8e74e753c] (rid 122187) by dkf on 2003-07-10 22:31:28:

    1. assignee changed to: "hobbs"
    2. icomment:
      Logged In: YES 
      user_id=79902
      
      Behaviour in this case is undocumented (!) but since the 
      primary purpose of the [binary] command is interaction with 
      the system, I'm tempted to say that we will handle the a and 
      A formats using [encoding system].  The alternative is to 
      drop the high bytes (which is what happens now) but that's 
      not nice at all.
      
      So, proposed change:
        [binary format a* $str] to use [encoding system] when 
      converting to a byte-stream (which is inserted in the 
      resulting bytearray.)  Hence we also use [encoding system] 
      when going the other way too.
      
      Net result is that the attached script will not work.  However 
      the following will:
        binary scan [binary format a* $foo] a* bar
      and the strings will be equal IF ALL THE CHARACTERS ARE 
      REPRESENTABLE IN THE SYSTEM ENCODING (which will be 
      fine most of the time.)
      
      Any comments Jeff?  If you approve, assign it back to me and 
      I'll develop a fix.
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. username: "dkf"
  7. Ticket change [3c1faa6df2] (rid 120867) by samoc on 2003-07-11 08:46:49:

    1. icomment:
      Logged In: YES 
      user_id=737265
      
      The manual page says "a: Stores a character string..." and it says
      "If count is *, then all of the bytes in arg will be formatted."
      In Tcl strings are UTF-8, if all the bytes are going to be formatted, 
      then they all need to end up in the result string, without any 
      conversion happening.
      I think the UTF-8 string should be copied verbatim into the "binary 
      format" result. This seems like a sensible behaviour since it 
      preserves the current behaviour for plain ascii strings.
      [binary format a* $x] == $x should hold for any value of x.
      
      (I imagine the current behaviour for "a7" would be unpredictable 
      as well given that the man page talks about bytes not characters.)
      
      Sam
      
      P.S. I am the original submitter.
      
      P.P.S. We have worked arround the bug by changing:
          set r  [binary format iia*i $i $j $s $k]
      to
          set r [binary format ii $i $j]
          append r $s
          append r [binary format i $k]
      
      I think that the "a" encoding should either be removed (since it 
      does no formatting anyway) or be changed to behave as described 
      above.
      
      
    2. login: "samoc"
    3. mimetype: "text/plain"
    4. username: "samoc"
  8. Ticket change [00d1b99ade] (rid 119376) by dkf on 2003-07-12 04:23:17:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      It is now documented that high bytes are *stripped*.  That
      was always the way - the docs just weren't updated when
      unicode was introduced with 8.1 - but it is now documented
      as such.
      
      Leaving this bug open as it is asking for something that
      possibly ought to work but definitely doesn't right now...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  9. Ticket change [030b91a813] (rid 119753) by hobbs on 2003-07-17 05:27:04:

    1. assignee changed to: "dkf"
    2. icomment:
      Logged In: YES 
      user_id=72656
      
      I'm conflicted as to whether that doc fix was correct.  I think 
      this is a problem in binary that was just never resolved.  One 
      may think that a == ascii, and that stripping the high bytes is 
      correct.  But that seems to be the purpose of 'c', correct?  Of 
      course, the fact that 'A' means space instead of null padding 
      versus the LE vs BE of the other small/large reps shows that 
      the designers never intended to support multi-byte chars 
      with 'a'.  I think we need to leave this as is, with improved 
      docs, and add 'u' and 'U' for unicode chars.
      
      
    3. login: "hobbs"
    4. mimetype: "text/plain"
    5. resolution changed to: "Remind"
    6. title changed to: "binary format a* $utf8_string - needs u/U"
    7. username: "hobbs"
  10. Ticket change [f3af588d2a] (rid 129756) by dkf on 2003-07-17 16:29:58:

    1. assignee changed to: "nobody"
    2. foundin changed to: "None"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      The docs are more than a bit flawed, but then so is
      particularly the 'A' specifier.
      
      'u' and 'U' specifiers are a good idea (though I'd prefer a
      way to insert strings of a specified encoding, with the
      system encoding as default) but require a TIP.  Switching
      this bug to the FRQ track.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. subsystem changed to: "None"
    7. username: "dkf"
  11. Ticket change [86cbe97720] (rid 131581) by dkf on 2003-07-17 17:13:36:

    1. subsystem changed to: "12. ByteArray Object"
  12. Ticket change [31a352537c] (rid 93464) by samoc on 2003-07-18 07:32:51:

    1. icomment:
      Logged In: YES 
      user_id=737265
      
      It seems to me that there is a simple solution to this problem.
      
      The purpose of binary format is to convert numeric values into
      specified binary representations. "a" and "A" are the only two
      types that don't convert some kind of numeric value. They are
      also uniqie in that they in fact do no conversion at all, they just
      dump a character string into the output.
      Perhaps the reason that no elegant solution presents itself here is
      that character strings have no place in binary format.
      
      I suggest simply depricating "a" and "A". As it stands they are not
      backwards compatible anyway since they don't work with multi-
      byte cahracters, and Tcl is supposed to support these
      transparently.
      If you have code like this
        set foo [binary format iai $x $s $y]
      do this instead:
        set foo [binary format i $x]$s[binary format i $y]
      and if the $s dosn't come out the way you want, use the usual
      encoding commands to deal with it.
      
      If "a" and "A" are to be kept I would suggest that they should
      take the string verbatim in its _current_ encoding. (not the system
      encoding) So if you want somthing else you could do:
        set foo [binary format iai $x [encoding convertto foo $a] $y]
      
      Sam
      
      
    2. login: "samoc"
    3. mimetype: "text/plain"
    4. username: "samoc"
  13. Ticket change [f3416ceab8] (rid 129677) by dgp on 2003-11-13 05:53:39:

    1. assignee changed to: "hobbs"
  14. Ticket change [cecadba80b] (rid 96110) by dkf on 2004-06-16 05:21:22:

    1. status changed to: "Closed"
  15. Ticket change [62116b3af7] (rid 92352) by dkf on 2004-06-16 05:21:23:

    1. assignee changed to: "dkf"
    2. icomment:
      Logged In: YES 
      user_id=79902
      
      Reevaluating this FRQ indicates that the original code
      should never have worked, but the following should:
      
        set tmp [encoding convertto utf-8 $foo]
        set tmp [binary format a* $tmp]
        set bar [encoding convertfrom utf-8 $tmp]
      Following this, $foo and $bar should be identical, and this
      will hold true for any encoding instead of utf-8 as long as
      all the characters in $foo are representable within that
      encoding.
      
      Given that, I've updated the docs to be clearer and contain
      an example that shows the handling of non-ASCII data. Future
      problems are now "pilot error"...
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. resolution changed to: "Rejected"
    6. username: "dkf"
  16. Ticket change [a5c5cb143a] (rid 110433) by dkf on 2004-06-16 05:21:24:

    1. closedate changed to: "2004-06-15T22:21:24"
    2. closer changed to: "dkf"