Overview
| Artifact ID: | 0cd381f658175dc5573f0e17f4de37f34e00a20a |
|---|---|
| Ticket: | 950acd6df4cffdac6dfecd189864e86262c33ea5
utf-8 to unicode conversion gives broken results |
| User & Date: | anonymous on 2014-02-24 09:49:39 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
So far as I understood "encoding convertfrom $enc $text" is the right command to convert from a string with known encoding to unicode. This works fine, except $enc is utf-8. Please try the following script (I hope this tracker is not corrupting the Greek): ---------------------------------------------------------------------- #!/usr/bin/wish # 1. ensure you have the right encoding to read the string # 2. we want conversion utf-8 -> unicode encoding system utf-8 set src "Η Σάμος είναι" # the result of this operation is broken! set uni [encoding convertfrom utf-8 $src] set utf [encoding convertto utf-8 $uni] # this works fine, it's a iso8859-7 encoded string set grk [encoding convertfrom iso8859-7 "Ç ÓÜìïò åßíáé"] pack [label .l1 -text $src] pack [label .l2 -text $uni] pack [label .l3 -text $utf] pack [label .l4 -text $grk] ---------------------------------------------------------------------- You will see that the conversion from utf-8 is broken. Converting back is still broken. Conversion from iso8859-7 is fine. My application is only working if I exclude utf-8 explicitly (my system encoding is utf-8): if {$encoding eq "utf-8"} { set dst $src ;# because convertfrom doesn't work } else { set dst [encoding convertfrom $encoding $src] } But I don't think that this is intended, the generic command "convertfrom" should work with all encodings due to the manual. PS: In my tests I've figured out that sometimes the conversion to utf-8 gives results with overlong sequences, such results are invalid due to the utf-8 specification. - foundin changed to: "Tcl 8.6.0 (pl10)"
- is_private changed to: "0"
- login: "anonymous"
- priority changed to: "5 Medium"
- private_contact changed to: "9b7155594aadef44d10a978838b8fe108cdafdd1"
- resolution changed to: "None"
- severity changed to: "Critical"
- status changed to: "Open"
- submitter changed to: "anonymous"
- subsystem changed to: "11. Conversions From String"
- title changed to: "utf-8 to unicode conversion gives broken results"
- type changed to: "Bug"