Shift_jis encoding issue?

Discussion in 'Ruby' started by Kev Jackson, Mar 27, 2006.

  1. Kev Jackson

    Kev Jackson Guest

    Not sure what's happening here:

    I have a yml file with the following

    address_1: '和歌山県和歌山市'

    I'm loading this into a structure (@test_data) and then accessing it to
    insert the values into text_fields in ie through watir. So basically I'm
    relying on a few thousand dependencies :0

    In VIM, the value in the yml file is correct, but when I print out the
    value to the cmd prompt, I get :

    "\230a\211\314\216R\214\247\230a\211\314\216R\216s"

    Which looks like a classic encoding issue (using 3 byte rather than 2 or
    vice-versa).

    Given that Ruby hails from Japan, I'd have thought that someone has seen
    something similar to this and would have a work-around/solution.
    Googling hasn't provided me with anything so far. Right now I'm not sure
    if this is a YAML/Syck issue, a Ruby issue, a or Windows issue. I have
    installed the Japanese laguage pack on windows and all the text from the
    server is displayed correctly in IE, so my guess is that Windows is
    configured correctly. As I mentioned, VIM is displaying the text
    correctly, so it seems to be saved to the file-system using the correct
    encoding, but after reading using YAML it doesn't appear to be using the
    same encoding...

    I've just tried require 'jcode' to see if this resolves it - so far no luck

    Any help greatly appreciated

    Thanks
    KEv
    Kev Jackson, Mar 27, 2006
    #1
    1. Advertising

  2. Kev Jackson

    Kev Jackson Guest

    Ok, some more info:

    $KCODE = 'SHIFT_JIS'
    require 'jcode'

    semi-works!

    I can print the correct value out to the cmd prompt with a simple:
    p @test_data['pg_401']['address_1']

    However with:
    @@ie.text_field:)id,
    @test_data['pg_401']['address_1_field']).set(@test_data['pg_401']['address_1'])

    I'm getting garbage. Now I've just tested copy/paste manually into ie
    and that works fine, so it looks like YAML/Syck is off the hook and now
    it seems to be more of a Watir problem.

    Thanks
    Kev
    Kev Jackson, Mar 27, 2006
    #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. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,796
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. MWells

    Url encoding issue; + v. %2B

    MWells, Jan 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    11,543
    MWells
    Jan 15, 2005
  3. Replies:
    1
    Views:
    23,312
    Real Gagnon
    Oct 8, 2004
  4. Replies:
    1
    Views:
    362
    Peter J. Holzer
    Apr 22, 2006
  5. Replies:
    2
    Views:
    352
Loading...

Share This Page