|
2023-07-05
| ||
| 10:15 | • Closed ticket [9bad909c6e]: jis0208 encoding fails for ASCII input plus 6 ot... artifact: 8ab12cb6a0 user: apnadkarni | |
|
2021-06-12
| ||
| 10:18 | • Ticket [9bad909c6e]: 3 changes artifact: 6f50a3e461 user: apnadkarni | |
| 06:18 | • New ticket [9bad909c6e]. artifact: f0444edf20 user: apnadkarni | |
jis0208 encoding fails for ASCII input
Closed / Invalid9bad909c6ed4691bcad1886d710a923791a524a2Created 5 years agoUpdated 3 years ago
Descriptionplain2021-06-12 06:18:05
Question for someone well versed in encodings - is the following not supposed to work? % set x "abc\u543e" abc吾 % encoding convertfrom jis0208 [encoding convertto jis0208 $x] ???吾 Or % string equal \u543e [encoding convertfrom jis0208 [encoding convertto jis0208 \u543e]] 1 (as expected) % string equal a [encoding convertfrom jis0208 [encoding convertto jis0208 a]] 0 (broken) % binary encode hex [encoding convertto jis0208 a] 2129 That does not seem correct. At least as per http://x0213.org/codetable/jisx0213-2004-8bit-std.txt Also tried with some older versions - 8.5.17 and 8.6.3 fail in similar fashion.
apnadkarniplain2021-06-12 10:18:01
From the Tclers' chat: aspect: Even with preference for doubl width encoding convertto and convertfrom should match" ... well, necessarily not always if (what seems to be the current interpretation) only fullwidth Latin characters exist in the target set, then "a" can't round-trip 2:38 if the encoding interprets what's in that table to mean that both u+0061 and u+ff41 map to the same encoding, then only one of those can round-trip apn: @aspect, I wasn't even aware there was a full width a (thereby showing my ignorance in this area). So are you saying it is not a bug because no round tripping is possible? aspect: well it might be a bug - bit even if it is, some round trips will not be possible. I don't know whether it's better for jis0209 to map ascii latin characters vs fullwidth versions, or if the version of [encoding convertto] that takes both to the same codepoints is a good idea pooryorick: apn, the bug is that [encoding convertfrom] converts one character to another character. pooryorick: aspect, why should [enocding convertfrom] convert a narrow "a" to a wide "a"? aspect: It doesn't [encoding convertfrom jis0208 [encoding convertto jis0208 a\uff41]] produces "\uff1f\uff41". That matches the intermediate encoded bytes. The change is when convertto doesn't know how to encode "a" so it subtitutes a fullwidth question mark So I do not know if this is a real bug or not. It was certainly surprising behavior to me. I'll leave open for someone knowledgeable to mark appropriately.
apnadkarniplain2023-07-05 10:15:12
Closing as not a bug. Agreed with @aspect's explanation now that I understand encodings better.
Log in (anonymous is fine) to add a comment.