[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Convert ç®?ä½?中æ?? in Chinese to 简体中文&

Stedwick

12/11/2007 5:39:00 PM

ç®?ä½?中æ??

converts to

简体中文


using this utility:
http://people.w3.org/rishida/scripts/uniview/conv...

Is there a way that I can get Ruby to do this for me?

Thanks!

Philip
--
Posted via http://www.ruby-....

3 Answers

Daniel Berger

12/11/2007 7:30:00 PM

0



On Dec 11, 10:39 am, Philip Brocoum <philip.broc...@gmail.com> wrote:
> =BC=F2=CC=E5=D6=D0=CE=C4
>
> converts to
>
> &#31616;&#20307;&#20013;&#25991;&#10;
>
> using this utility:http://people.w3.org/rishida/scripts/uniview/c...
php
>
> Is there a way that I can get Ruby to do this for me?

string =3D "=BC=F2=CC=E5=D6=D0=CE=C4"
p string.unpack("U*").map{ |c| c =3D "&##{c};"}.join =3D>
"&#31616;&#20307;&#20013;&#25991;"

I'm not sure what the "&#10;" is. Whitespace? Should be "&#32;" then.

Regards,

Dan

Suraj Kurapati

12/11/2007 9:40:00 PM

0

Philip Brocoum wrote:
> ç®?ä½?中æ??
>
> converts to
>
> &#31616;&#20307;&#20013;&#25991;&#10;
>
> Is there a way that I can get Ruby to do this for me?

>> "ç®?ä½?中æ??"
=> "\347\256\200\344\275\223\344\270\255\346\226\207"
>> "ç®?ä½?中æ??".unpack('U*')
=> [31616, 20307, 20013, 25991]
>> "ç®?ä½?中æ??".unpack('U*').map {|c| "&#{c};"}
=> ["&31616;", "&20307;", "&20013;", "&25991;"]
>> "ç®?ä½?中æ??".unpack('U*').map {|c| "&#{c};"}.join
=> "&31616;&20307;&20013;&25991;"
--
Posted via http://www.ruby-....

Stedwick

12/11/2007 9:59:00 PM

0

wow, thanks!
--
Posted via http://www.ruby-....