Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-12-08
20:45 • Ticket [2910093fff] Byte-order mark symbol is decoded as \uFEFF status still... artifact: 4f4c70e082 user: dgp
20:45 • Ticket [2910093fff]: 4 changes artifact: 367c521a4d user: dgp
18:36 • Ticket [2910093fff]: 7 changes artifact: 17231c160a user: dkf
2009-12-07
23:33 • Ticket [2910093fff]: 4 changes artifact: ec301dc35a user: a_kovalenko
16:13 • New ticket [2910093fff]. artifact: 4e3967699d user: a_kovalenko

Byte-order mark symbol is decoded as \uFEFF

Open2910093fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-12-07 16:13:53
There is a byte-order mark mechanism in Unicode encodings, used to identify the byte-order of UCS2, UCS4 etc, and to identify that the stream IS utf-8.
When a string is converted from utf-8 (or from "unicode", which is UCS2 in native byte order), byte-order mark becomes \uFEFF and appears in the output.

It's theoretically useful for applications that have to distinguish between marked and unmarked files or strings, but it creates obscure difficulties for all other applications. I don't know what should be done (ignoring BOM when converting from utf-8 may be not a good option), but we need at least _some_ way to convert data from unicode/utf-8 that doesn't leave byte order mark in the internal string representation.

Maybe some new encoding(s) should be introduced, like unicode-bom (autodetecting between utf-8,ucs2-LE/BE etc on input, stripping BOM on input, appending BOM on output). I'm not sure what is to be done (and even unsure that the problem is to be solved on TCL level).
a_kovalenkoplain2009-12-07 23:33:39
On the second thought, maybe it should be handled when reading the utf8-encoded channel; something like fconfigure $fh -ignorebom true, or -bomchar \uFEFF, to skip BOM when reading the file. Other conversions done on the channel level (CR/LF/EOF) are "of the same spirit", so to speak.
dkfplain2009-12-08 18:36:08
data_type - 360894
dgpplain2009-12-08 20:45:23
I like the channel options approach better myself.
dgp Ticket [2910093fff]: 2 changes [History diff]2009-12-08 20:45:24
Log in (anonymous is fine) to add a comment.