[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Lyrics and Chinese in Ruby?

Apple

1/21/2008 10:34:00 AM

Hello, has anyone used Chinese with Ruby? I'm trying to write a
script that would import/export my lyrics from/to lyricwiki.org.
Since they don't have a lot of Chinese lyrics, I thought I'd help them
out by exporting my collection. Looking at their SOAP API wiki
(http://lyricwiki.org/Lyri...), they seem have some troubles
encoding and decoding Unicode characters using Ruby's soap/
wsdlDriver. I tried to run my songs' meta data through rubyosa. But
I have no luck.

Here's a few songs I've tried out by copy-pasting the artist and song
names into the source and fetching the lyrics:
http://lyricwiki.org/Category:Language....

And here is a simple script, I've been testing with (w/ RubyOSA):
http://pastie.caboo...

My system is running on MacOS Leopard, Ruby 1.8.6. Thanks in advance
for all your help!

David
1 Answer

hengist podd

1/23/2008 11:07:00 AM

0

On 21 Jan, 10:34, NewtonApple <newtonap...@gmail.com> wrote:
> Hello, has anyone used Chinese with Ruby?  I'm trying to write a
> script that would import/export my lyrics from/to lyricwiki.org.
> Since they don't have a lot of Chinese lyrics, I thought I'd help them
> out by exporting my collection.  Looking at their SOAP API wiki
> (http://lyri...Lyri...), they seem have some troubles
> encoding and decoding Unicode characters using Ruby's soap/
> wsdlDriver.

Looks like something's hosed somewhere:

require 'soap/wsdlDriver'
driver = SOAP::WSDLDriverFactory.new("http://lyri...s...
wsdl").create_rpc_driver

p driver.getSong("La Mosca Ts\303\251-Ts\303\251","Madrid Amaneci
\303\263").artist
# "La Mosca Ts\303\203\302\203\303\202\302\251-Ts
\303\203\302\203\303\202\302\251" (!)

Same problem seems to happen on Python, which suggests the problem
might be on the server side:

import LyricWiki_services

soap = LyricWiki_services.LyricWikiBindingSOAP('http://lyri...
server.php')
song = LyricWiki_services.getSongRequest()
song.Artist = unicode('La Mosca Ts\xc3\xa9-Ts\xc3\xa9', 'utf8')
song.Song = unicode('Madrid Amaneci\xc3\xb3', 'utf8')
result = soap.getSong(song)

print `result.Return.Artist.encode('utf8')`
# 'La Mosca Ts\xc3\x83\xc2\x83\xc3\x82\xc2\xa9-Ts
\xc3\x83\xc2\x83\xc3\x82\xc2\xa9'

You might want to speak to the LyricWiki folks about that.


> And here is a simple script, I've been testing with (w/RubyOSA):http://pastie.caboo...

Note that this script won't work as-is for non-English names since
RubyOSA uses ASCII by default, although this can be changed.
Alternatively, use rb-appscript, which uses UTF8 by default.

HTH

has
--
http://appscript.sourc...
http://rb-appscript.rub...