# Shift\_jis encoding issue?

**URL:** <https://www.ruby-forum.com/t/shift-jis-encoding-issue/56015>\
**Category:** Ruby\
**Created:** [March 27, 2006, 11:35am UTC](https://www.ruby-forum.com/t/shift-jis-encoding-issue/56015 "2006-03-27T11:35:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kev\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/2bfe46/32.png) [@Kev\_J](https://www.ruby-forum.com/u/Kev_J)\
**Post date:** [March 27, 2006, 11:35am UTC](https://www.ruby-forum.com/t/shift-jis-encoding-issue/56015/1 "2006-03-27T11:35:05Z")

</div>

Not sure what’s happening here:

I have a yml file with the following

address\_1: ‘e$BOB2N;38)OB2N;3;Te(B’

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

---

<div class="post-metadata">

**Author:** ![Kev\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/2bfe46/32.png) [@Kev\_J](https://www.ruby-forum.com/u/Kev_J)\
**Post date:** [March 27, 2006, 11:49am UTC](https://www.ruby-forum.com/t/shift-jis-encoding-issue/56015/2 "2006-03-27T11:49:37Z")

</div>

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
