# UTF char issue

**URL:** <https://www.ruby-forum.com/t/utf-char-issue/155121>\
**Category:** Ruby\
**Created:** [December 8, 2008, 11:41am UTC](https://www.ruby-forum.com/t/utf-char-issue/155121 "2008-12-08T11:41:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![abirami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@abirami](https://www.ruby-forum.com/u/abirami)\
**Post date:** [December 8, 2008, 11:41am UTC](https://www.ruby-forum.com/t/utf-char-issue/155121/1 "2008-12-08T11:41:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abirami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@abirami](https://www.ruby-forum.com/u/abirami)\
**Post date:** [December 8, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/utf-char-issue/155121/2 "2008-12-08T16:20:53Z")

</div>

2008/12/8 Abirami S. [removed\_email\_address@domain.invalid](mailto: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

---

<div class="post-metadata">

**Author:** ![abirami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@abirami](https://www.ruby-forum.com/u/abirami)\
**Post date:** [December 9, 2008, 6:02am UTC](https://www.ruby-forum.com/t/utf-char-issue/155121/3 "2008-12-09T06:02:49Z")

</div>

Stefan L. wrote:

> 2008/12/8 Abirami S. [removed\_email\_address@domain.invalid](mailto: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.

---

<div class="post-metadata">

**Author:** ![abirami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@abirami](https://www.ruby-forum.com/u/abirami)\
**Post date:** [December 9, 2008, 6:23am UTC](https://www.ruby-forum.com/t/utf-char-issue/155121/4 "2008-12-09T06:23:23Z")

</div>

Hi,

In message “Re: UTF char issue”  
on Tue, 9 Dec 2008 13:57:07 +0900, Abirami S.  
[removed\_email\_address@domain.invalid](mailto: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.

```

---

<div class="post-metadata">

**Author:** ![abirami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@abirami](https://www.ruby-forum.com/u/abirami)\
**Post date:** [December 9, 2008, 6:49am UTC](https://www.ruby-forum.com/t/utf-char-issue/155121/5 "2008-12-09T06:49:50Z")

</div>

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](mailto: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

---

<div class="post-metadata">

**Author:** ![abirami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@abirami](https://www.ruby-forum.com/u/abirami)\
**Post date:** [December 9, 2008, 7:03am UTC](https://www.ruby-forum.com/t/utf-char-issue/155121/6 "2008-12-09T07:03:43Z")

</div>

Hi,

In message “Re: UTF char issue”  
on Tue, 9 Dec 2008 14:43:15 +0900, Abirami S.  
[removed\_email\_address@domain.invalid](mailto: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.

```
