Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

read a file

20 views
Skip to first unread message

DrS

unread,
Feb 10, 2012, 4:00:10 PM2/10/12
to
Does anyone have a quick way of reading utf-16 data files created on
Windows with Unicode encoding? When I read the file in tkcon, it seems
that each character is double spaced which lead to some strange problems
like some character comparisons no longer working.

DrS

Robert Heller

unread,
Feb 10, 2012, 4:52:56 PM2/10/12
to
set channel [open filename.dat r]
fconfigure $channel -encoding utf-16

>
>

--
Robert Heller -- 978-544-6933 / hel...@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments



DrS

unread,
Feb 10, 2012, 5:00:50 PM2/10/12
to
On 2/10/2012 4:52 PM, Robert Heller wrote:
>
> set channel [open filename.dat r]
> fconfigure $channel -encoding utf-16
>
>>
>>
>

Is that a valid encoding? I am getting this error:

% fconfigure $channel -encoding utf-16
unknown encoding "utf-16"

I am using Tcl8.4 if that is relevant.

DrS


Aric Bills

unread,
Feb 10, 2012, 5:12:47 PM2/10/12
to
As far as I know, Tcl doesn't ship with a utf-16 encoding. If I
remember correctly, the "unicode" encoding is UCS-2, which is a subset
of utf-16. See if that works for you.

DrS

unread,
Feb 10, 2012, 5:15:55 PM2/10/12
to
On 2/10/2012 5:12 PM, Aric Bills wrote:
>
> As far as I know, Tcl doesn't ship with a utf-16 encoding. If I
> remember correctly, the "unicode" encoding is UCS-2, which is a subset
> of utf-16. See if that works for you.

You are correct. I tried unicode and it works fine.

Thanks to both of you!


DrS
0 new messages