Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Convert 简体ä¸*æ–‡ in Chinese to 简体中文&

Reply
Thread Tools

Convert 简体ä¸*æ–‡ in Chinese to 简体中文&

 
 
Philip Brocoum
Guest
Posts: n/a
 
      12-11-2007
简体ä¸*æ–‡

converts to

简体中文

using this utility:
http://people.w3.org/rishida/scripts...conversion.php

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

Thanks!

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

 
Reply With Quote
 
 
 
 
Daniel Berger
Guest
Posts: n/a
 
      12-11-2007


On Dec 11, 10:39 am, Philip Brocoum <philip.broc...@gmail.com> wrote:
> =BC=F2=CC=E5=D6=D0=CE=C4
>
> converts to
>
> 简体中文
>
> using this utility:http://people.w3.org/rishida/scripts...ew/conversion=

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>
"简体中文"

I'm not sure what the " " is. Whitespace? Should be " " then.

Regards,

Dan

 
Reply With Quote
 
 
 
 
Suraj Kurapati
Guest
Posts: n/a
 
      12-11-2007
Philip Brocoum wrote:
> 简体ä¸*æ–‡
>
> converts to
>
> 简体中文
>
> 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-forum.com/.

 
Reply With Quote
 
Philip Brocoum
Guest
Posts: n/a
 
      12-11-2007
wow, thanks!
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert ¼òÌåÖÐÎÄ in Chinese to &#31616;&#20307;&#20013;&#25991;&#10;? Stedwick Ruby 0 12-11-2007 04:45 PM
To convert to J2SE 6 or not to convert, that is the question... Jaap Java 4 07-10-2006 09:03 AM
Convert chinese text to GIF =?Utf-8?B?TWFyc2hhbGw=?= ASP .Net 1 02-11-2005 12:45 PM
Re: How do I translate a Chinese web site and add Chinese character set to IE..? =A0 - =A0 Taking these two questions one at a time... =A Patrick Dunford NZ Computing 3 04-28-2004 07:15 PM
Do I need to Convert with Convert.ToInt32(session("myNumber")) ? Andreas Klemt ASP .Net 1 07-23-2003 02:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57