Forum: Ruby UTF char issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aa9698375c67dacb97dafcaeefff7e3e?d=identicon&s=25 Abirami Selvam (abirami)
on 2008-12-08 11:41
While reading the data from the text file,the special characters has not
been printed as like in the file.

ex:

ë UTF char has changed into δ

Please help me out as soon as possible.....


Regards
Abirami S
40613e55d7082e5f08429dfb50d0680e?d=identicon&s=25 Stefan Lang (Guest)
on 2008-12-08 16:20
(Received via mailing list)
2008/12/8 Abirami Selvam <abirami.janu@gmail.com>:
> While reading the data from the text file,the special characters has not
> been printed as like in the file.
>
> ex:
>
> ë UTF char has changed into δ

Please post the code, and if possible, also the text file.
Then we may be able to help you.

Stefan
Aa9698375c67dacb97dafcaeefff7e3e?d=identicon&s=25 Abirami Selvam (abirami)
on 2008-12-09 06:02
Stefan Lang wrote:
> 2008/12/8 Abirami Selvam <abirami.janu@gmail.com>:
>> While reading the data from the text file,the special characters has not
>> been printed as like in the file.
>>
>> ex:
>>
>> ë UTF char has changed into δ
>
> Please post the code, and if possible, also the text file.
> Then we may be able to help you.
>
> Stefan

MEI-Tsjechië en Slowakije Fonds Acc
Skarbiec FIO Sub Zrównowazony Waga Acc
DnB NOR Øst-Europa Acc

These are the lines available in my txt file.

f= File.open(filename)
 f.each do |line|
   puts line
 end

Using the above code am reading the file and print the data.
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2008-12-09 06:23
(Received via mailing list)
Hi,

In message "Re: UTF char issue"
    on Tue, 9 Dec 2008 13:57:07 +0900, Abirami Selvam
<abirami.janu@gmail.com> writes:

|MEI-Tsjechië en Slowakije Fonds Acc
|Skarbiec FIO Sub Zrównowazony Waga Acc
|DnB NOR Øst-Europa Acc
|
|These are the lines available in my txt file.
|
|f= File.open(filename)
| f.each do |line|
|   puts line
| end
|
|Using the above code am reading the file and print the data.

It doesn't happen on me.  I am afraid that it's caused by encoding
mismatch, perhaps either your data or your console do not set to
UTF-8.

              matz.
Aa9698375c67dacb97dafcaeefff7e3e?d=identicon&s=25 Abirami Selvam (abirami)
on 2008-12-09 06:49
Attachment: UTF-Char_issue.doc (50 KB)
Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: UTF char issue"
>     on Tue, 9 Dec 2008 13:57:07 +0900, Abirami Selvam
> <abirami.janu@gmail.com> writes:
>
> |MEI-Tsjechi� en Slowakije Fonds Acc
> |Skarbiec FIO Sub Zr�wnowazony Waga Acc
> |DnB NOR �st-Europa Acc
> |
> |These are the lines available in my txt file.
> |
> |f= File.open(filename)
> | f.each do |line|
> |   puts line
> | end
> |
> |Using the above code am reading the file and print the data.
>
> It doesn't happen on me.  I am afraid that it's caused by encoding
> mismatch, perhaps either your data or your console do not set to
> UTF-8.
>
>               matz.

While running the same code in SCITE editor it is working fine. Am using
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]. For more
information Please find the attachment
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2008-12-09 07:03
(Received via mailing list)
Hi,

In message "Re: UTF char issue"
    on Tue, 9 Dec 2008 14:43:15 +0900, Abirami Selvam
<abirami.janu@gmail.com> writes:

|While running the same code in SCITE editor it is working fine. Am using
|ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]. For more
|information Please find the attachment

I believe your console lacks ability to print UTF-8 characters.  Even
simple 'type sample.txt' can cause your "problem".  So it's not Ruby's
fault at all.

              matz.
This topic is locked and can not be replied to.