# Reding unicode characters?

**URL:** <https://www.ruby-forum.com/t/reding-unicode-characters/131443>\
**Category:** Ruby\
**Created:** [March 10, 2008, 4:37am UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443 "2008-03-10T04:37:22Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 10, 2008, 4:37am UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/1 "2008-03-10T04:37:22Z")

</div>

Hi friends,

Could any one help me in writing a method which reads all Unicode  
characters supported in ruby or else using regular expressions.

Thanks in advance,

Regards,  
Jose Martin

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 10, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/2 "2008-03-10T16:00:21Z")

</div>

dare ruby wrote:

> Hi friends,
> 
> Could any one help me in writing a method which reads all Unicode  
> characters supported in ruby or else using regular expressions.
> 
> Thanks in advance,
> 
> Regards,  
> Jose Martin

Ruby does not support unicode.

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 10, 2008, 4:14pm UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/3 "2008-03-10T16:14:45Z")

</div>

On Mar 10, 2008, at 10:00 AM, 7stud – wrote:

> > Jose Martin
> 
> Ruby does not support unicode.

Really?

$ ruby -KU -r jcode -e ‘p “Résumé”.jsize’  
6

James Edward G. II

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 11, 2008, 4:15am UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/4 "2008-03-11T04:15:41Z")

</div>

Is there any possibilities using regular expressions or writing own  
methods for unicode charatcers?

> > Ruby does not support unicode.
> 
> Really?
> 
> $ ruby -KU -r jcode -e ‘p “Rï¿½sumï¿½”.jsize’  
> 6
> 
> James Edward G. II

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 11, 2008, 4:30am UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/5 "2008-03-11T04:30:05Z")

</div>

James G. wrote:

> On Mar 10, 2008, at 10:00 AM, 7stud – wrote:
> 
> > > Jose Martin
> > 
> > Ruby does not support unicode.
> 
> Really?
> 
> $ ruby -KU -r jcode -e ‘p “Résumé”.jsize’  
> 6
> 
> James Edward G. II

How does that prove the ruby supports unicode? Where are there any  
unicode characters in your string?

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 11, 2008, 11:06am UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/6 "2008-03-11T11:06:44Z")

</div>

7stud – wrote:

> James G. wrote:
> 
> > […]  
> > $ ruby -KU -r jcode -e ‘p “Rï¿½sumï¿½”.jsize’  
> > 6
> > 
> > James Edward G. II
> 
> How does that prove the ruby supports unicode? Where are there any  
> unicode characters in your string?

1/ There’s a difference between codepoints and characters, speaking of  
unicode “characters” is confusing at best.

2/ “Supporting unicode” is probably meaningless (which unicode encoding  
by the way?), building UTF-8 applications in Ruby is perfectly doable  
thanks to jcode, regex UTF-8 support, … I know, among other things  
it’s what I built my company on.

The example above obviously assumes an UTF-8 locale in the terminal you  
type it…  
For more data, just try size instead of jsize in the same example and  
read jcode’s rdoc.

Lionel

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 11, 2008, 1:50pm UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/7 "2008-03-11T13:50:15Z")

</div>

On Mar 10, 2008, at 10:29 PM, 7stud – wrote:

> > 6
> > 
> > James Edward G. II
> 
> How does that prove the ruby supports unicode?

If the code was not character aware, it would have returned a count of  
the bytes in the String (more than six). String#size, for example.

> Where are there any unicode characters in your string?

I entered the accented e characters in UTF-8, that’s why you see the -  
KU switch to tell Ruby the encoding.

James Edward G. II

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 11, 2008, 5:36pm UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/8 "2008-03-11T17:36:20Z")

</div>

On Tue, Mar 11, 2008 at 7:49 AM, James G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> James Edward G. II  
> I think this may have been discussed before, but -KU doesn’t work for  
> me on Windows XP. I get an unterminated string error with the  
> “Résumé” UTF-8 encoded string. I can only assume that the parser is  
> still interpreting the string as one byte per character. Anyone have  
> any ideas?

Todd

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 11, 2008, 6:13am UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/9 "2008-03-11T06:13:34Z")

</div>

Hi,

In message “Re: Reding unicode characters?”  
on Tue, 11 Mar 2008 12:29:58 +0900, 7stud –  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|How does that prove the ruby supports unicode? Where are there any  
|unicode characters in your string?

Then, tell me what makes you think it’s proven.

```
          matz.

```

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 11, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/10 "2008-03-11T17:50:01Z")

</div>

> Todd B. wrote:  
> On Tue, Mar 11, 2008 at 7:49 AM, James G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > James Edward G. II  
> > I think this may have been discussed before, but -KU doesn’t work for  
> > me on Windows XP. I get an unterminated string error with the  
> > “Rï¿½sumï¿½” UTF-8 encoded string. I can only assume that the parser is  
> > still interpreting the string as one byte per character. Anyone have  
> > any ideas?
> 
> Todd

Maybe try a regex-based UTF-8 hack (Ruby 1.8.6) like here:  
[http://snippets.dzone.com/posts/show/4527](http://snippets.dzone.com/posts/show/4527)

Cheers,  
jk

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 11, 2008, 6:21pm UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/11 "2008-03-11T18:21:01Z")

</div>

On Tue, Mar 11, 2008 at 11:49 AM, Jimmy K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Maybe try a regex-based UTF-8 hack (Ruby 1.8.6) like here:  
> [http://snippets.dzone.com/posts/show/4527](http://snippets.dzone.com/posts/show/4527)
> 
> Cheers,  
> jk

Thanks for the pointer!

Todd

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 12, 2008, 12:44am UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/12 "2008-03-12T00:44:49Z")

</div>

James G. wrote:

> On Mar 10, 2008, at 10:29 PM, 7stud – wrote:
> 
> > > 6
> > > 
> > > James Edward G. II
> > 
> > How does that prove the ruby supports unicode?
> 
> If the code was not character aware, it would have returned a count of  
> the bytes in the String (more than six). String#size, for example.
> 
> > Where are there any unicode characters in your string?
> 
> I entered the accented e characters in UTF-8, that’s why you see the -  
> KU switch to tell Ruby the encoding.
> 
> James Edward G. II

Ahh, I see. You think UTF-8 is unicode. And apparently you think that  
when you enter a UTF-8 character in a post that everyone will see the  
character you entered.

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [March 12, 2008, 2:42am UTC](https://www.ruby-forum.com/t/reding-unicode-characters/131443/13 "2008-03-12T02:42:54Z")

</div>

On Mar 11, 2008, at 6:46 PM, 7stud – wrote:

> > of  
> > Ahh, I see. You think UTF-8 is unicode.  
> > I this UTF-8 is an encoding of Unicode.

> And apparently you think that when you enter a UTF-8 character in a  
> post that everyone will see the character you entered.

I think I included the -KU switch to show you exactly what was going on.

I also think it was pointless for you to be rude about this, so I  
guess you succeeding in proving that what I think doesn’t always matter.

James Edward G. II  
D
