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.
Abirami S. (Guest)
on 2008-12-08 12: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
Stefan L. (Guest)
on 2008-12-08 17:20
(Received via mailing list)
2008/12/8 Abirami S. <removed_email_address@domain.invalid>:
> 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
Abirami S. (Guest)
on 2008-12-09 07:02
Stefan L. wrote:
> 2008/12/8 Abirami S. <removed_email_address@domain.invalid>:
>> 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.
Yukihiro M. (Guest)
on 2008-12-09 07:23
(Received via mailing list)
Hi,

In message "Re: UTF char issue"
    on Tue, 9 Dec 2008 13:57:07 +0900, Abirami S.
<removed_email_address@domain.invalid> 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.
Abirami S. (Guest)
on 2008-12-09 07:49
Attachment: UTF-Char_issue.doc (0 Bytes)
Yukihiro M. wrote:
> Hi,
>
> In message "Re: UTF char issue"
>     on Tue, 9 Dec 2008 13:57:07 +0900, Abirami S.
> <removed_email_address@domain.invalid> 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
Yukihiro M. (Guest)
on 2008-12-09 08:03
(Received via mailing list)
Hi,

In message "Re: UTF char issue"
    on Tue, 9 Dec 2008 14:43:15 +0900, Abirami S.
<removed_email_address@domain.invalid> 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.