Reding unicode characters?

D

dare ruby

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
 
7

7stud --

dare said:
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.
 
D

dare ruby

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

7stud --

James said:
Really?

$ ruby -KU -r jcode -e 'p "Résumé".jsize'
6

James Edward Gray II

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

Lionel Bouton

7stud said:
James said:
[...]
$ ruby -KU -r jcode -e 'p "R�sum�".jsize'
6

James Edward Gray 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
 
J

James Gray

How does that prove the ruby supports unicode?

If the code was not character aware, it would have returned a count of =20=

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 -=20=

KU switch to tell Ruby the encoding.

James Edward Gray II
 
T

Todd Benson

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.



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

James Edward Gray 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=E9sum=E9" 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
 
J

Jimmy Kofler

Todd said:
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

Cheers,
jk
 
7

7stud --

James said:
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.


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

James Edward Gray 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.
 
J

James Gray

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 Gray II
D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,285
Messages
2,571,416
Members
48,107
Latest member
AmeliaAmad

Latest Threads

Top