Artifacts Associated With Ticket 0e92c404f1
Ticket change [ac313facd8] (rid 137810) by anonymous on 2014-04-30 16:54:49:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi all, I found one very confusing behavior in tcl. set x "\u5317\u4eac" # Beijing in Chinese set y $x puts "x: '$x' -> '[string range $x 0 100]''" puts "y: '$y'" encoding convertfrom "iso8859-1" $y puts "y: '$y'" # format "%s" $y puts "x: '$x' -> '[string range $x 0 100]'" output: x: '北京' -> '北京'' y: '北京' y: '北京' x: '北京' -> '¬' if we uncomment second to last line above output is ok: x: '北京' -> '北京'' y: '北京' y: '北京' x: '北京' -> '北京' encoding and format commands have side effects on string range command (In the second example they negate each other producing good result). Pay attention that neither x nor y were manipulated in any way. However string range command seems to be affected. I use tcl 8.5. Thanks, Nikola
- foundin initialized to: "tcl 8.5"
- is_private initialized to: "0"
- login: "anonymous"
- priority initialized to: "5 Medium"
- private_contact initialized to: "6b82a19e85309b70487c05b681a5f63a1a1d64bd"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "anonymous"
- subsystem initialized to: "16. Commands A-H"
- title initialized to:
Side effect on string range command (from encoding and format commands)
- type initialized to: "Bug"
Ticket change [685bd28123] (rid 137818) by jan.nijtmans on 2014-04-30 20:38:01:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2456778.35973868"
- closer changed to: "jan.nijtmans"
- icomment:
Fixed in [77a7d8d123] (core-8-5-branch). In trunk, the fix was already applied more than 5 years ago ([ee4709ceaf], thanks to dkf), so I just backported dkf's fix. Explanation: The "encoding convertfrom" command creates an internal byte array representation from the string, and "string range" tries to make smart use of the byte array representation. But that shortcut was simply wrong.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"