Lyrics and Chinese in Ruby?

Discussion in 'Ruby' started by NewtonApple, Jan 21, 2008.

  1. NewtonApple

    NewtonApple Guest

    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/LyricWiki:SOAP), 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/Cantonese.

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

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

    David
     
    NewtonApple, Jan 21, 2008
    #1
    1. Advertising

  2. NewtonApple

    has Guest

    On 21 Jan, 10:34, NewtonApple <> 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://lyricwiki.org/LyricWiki:SOAP), 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://lyricwiki.org/server.php?
    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://lyricwiki.org/
    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.se/141454


    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.sourceforge.net
    http://rb-appscript.rubyforge.org
     
    has, Jan 23, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gustavo Rahal

    first python program.. lyrics search

    Gustavo Rahal, Apr 3, 2004, in forum: Python
    Replies:
    1
    Views:
    495
    Mel Wilson
    Apr 3, 2004
  2. Replies:
    0
    Views:
    282
  3. Eric Schwartz

    Chinese Ruby books?

    Eric Schwartz, Feb 24, 2004, in forum: Ruby
    Replies:
    0
    Views:
    112
    Eric Schwartz
    Feb 24, 2004
  4. Nanyang Zhan
    Replies:
    29
    Views:
    370
    John Smith
    May 10, 2007
  5. bob
    Replies:
    1
    Views:
    152
    Axel Etzold
    Jun 14, 2007
Loading...

Share This Page