[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Individual char values in a Unicode string

Tim Bray

9/2/2006 4:45:00 AM

I'm trying to figure out how to use [] String or jconv or something =
=20
to figure out the actual code-point values in a Unicode/UTF-8 =20
string. For example, how can I write f such that

f('t=C3=B6=E4=B8=AD') =3D=3D> [ 0x74, 0xf6, 0x4e2d ]

(hex just for clarity of course, I want numbers).

-Tim

3 Answers

Paul Lutus

9/2/2006 5:07:00 AM

0

Tim Bray wrote:

> I'm trying to figure out how to use [] String or jconv or something
> to figure out the actual code-point values in a Unicode/UTF-8
> string. For example, how can I write f such that
>
> f('tö中') ==> [ 0x74, 0xf6, 0x4e2d ]
>
> (hex just for clarity of course, I want numbers).

Hex numbers are numbers. :)

To answer your question, you can extract bytes from a string:

#!/usr/bin/ruby

s = "this is a test"

i = 0
while (i < s.size)
puts s[i] # emits numbers, not characters
i += 1
end

Bu I don't think Ruby recognizes characters, Unicode or otherwise. So it may
not be able to interpret a mixture of Unicode and UTF/8 without explicit
code from the programmer.

--
Paul Lutus
http://www.ara...

Daniel Berger

9/2/2006 5:40:00 AM

0

Tim Bray wrote:
> I'm trying to figure out how to use [] String or jconv or something to
> figure out the actual code-point values in a Unicode/UTF-8 string.
> For example, how can I write f such that
>
> f('tö中') ==> [ 0x74, 0xf6, 0x4e2d ]
>
> (hex just for clarity of course, I want numbers).
>
> -Tim
>
>

'tö中'.unpack("U*") => [116, 246, 20013]

Regards,

Dan

ellie

11/14/2009 10:17:00 PM

0

On Nov 14, 10:38 am, Happy <happydrea...@hotmail.com> wrote:
> On Nov 14, 12:01 am, MikeRyder <n...@nospam.com> wrote:
>
>
>
> > On Fri, 13 Nov 2009 19:13:57 -0800 (PST), Happy
>
> > <happydrea...@hotmail.com> wrote:
> > >On Nov 13, 2:01 pm, MikeRyder <n...@nospam.com> wrote:
> > >> On Fri, 13 Nov 2009 11:58:51 -0800 (PST), Happy
>
> > >> <happydrea...@hotmail.com> wrote:
> > >> >On Nov 11, 4:04 pm, MikeRyder <n...@nospam.com> wrote:
> > >> >> On Wed, 11 Nov 2009 15:53:05 -0800 (PST), Happy
>
> > >> >> <happydrea...@hotmail.com> wrote:
> > >> >> >On Nov 11, 3:40 pm, MikeRyder <n...@nospam.com> wrote:
> > >> >> >> On Wed, 11 Nov 2009 15:30:05 -0800 (PST), george
>
> > >> >> >> <georgeculol...@hotmail.com> wrote:
> > >> >> >> >On Nov 11, 3:14 pm, Pieter <hrdou...@zonnet.nl> wrote:
> > >> >> >> >> On 11 nov, 23:06, MikeRyder <n...@nospam.com> wrote:
>
> > >> >> >> >> > On Wed, 11 Nov 2009 07:14:46 -0800 (PST), Happy
>
> > >> >> >> >> > <happydrea...@hotmail.com> wrote:
> > >> >> >> >> > >Since conflict is not real. Thank God, we can always choose once
> > >> >> >> >> > >again.
>
> > >> >> >> >> > Of course conflict is real.  
>
> > >> >> >> >> There is no conflict between
> > >> >> >> >> the truth and illusions.
> > >> >> >> >> Illusions battle only with themselves.
> > >> >> >> >> Conflict only seems to be real
> > >> >> >> >> when it is NOT brought to truth.
>
> > >> >> >> >> > Philosophical intellectualism doesnt cut
> > >> >> >> >> > it.
>
> > >> >> >> >> Revelation does.
>
> > >> >> >> >I'd say conflict is very real to people that don't understand that
> > >> >> >> >it's not real in truth but only an illusion and can be looked at a
> > >> >> >> >different way that shines away the illusion.
>
> > >> >> >> Oh good grief! Conflict is real to people who experience it. You
> > >> >> >> really need to stop denying your emotions.
>
> > >> >> >Sorry its not. Stop denying that!
>
> > >> >> See, this is the problem with your intellectualized take on acim.
> > >> >> You've intellectualized your humanity right out of your world.
>
> > >> >Are you in my head?
>
> > >> Well, i dont know. What exactly is IN your head?
> > >> lol
>
> > >> >I was just thinking the same thing about you.
>
> > >> Naw. Not even close.
>
> > >Closer than you could imagine.
>
> > Wow, how...spiritual...you sound.
>
> > lol
>
> Thank you. You sound very spiritual yourself, but not in an
> intellectual way at all.

lol