jssh (firefox) and unicode

6 views
Skip to first unread message

Stacia

unread,
Apr 30, 2009, 7:54:04 PM4/30/09
to Watir General
I've been working all day to try to get unicode displayed in text
fields properly. I've come to the conclusion that probably the JSSH
socket connection doesn't support having unicode sent over it - is
there anyone who can confirm this? I saw a fix for Chinese, but this
was for IE, and other fixes involved ugliness like using Excel. Every
time I try to send unicode data (encoded in various ways with
different libraries) the output is always junk. Would building Firefox
with JSSH support built in help at all? (not that it's an easy option
on windows, but still). I was trying to experiment with JSSH myself
using my own telnet client, but I couldn't find a unicode friendly
telnet client at all (not a good sign). I've tried everything: I
changed the default encoding of Firefox to utf8, I tried nkf, iconv,
and packing arrays of ints into unicode chars. All of these just
output junk (although the last method I could write to text files
fine) I've learned a lot about unicode in *Ruby* but if the problem is
unicode over JSSH that's beyond me.

I also have rewritten the doKeyPressMethod for quite a while now, it
looks like this:

class FireWatir::TextField
def doKeyPress( value )
@o.value = value
fire_key_events
end
end

this solves the slow text input problem on linux. I don't care about
inputting the text character by character, which may have caused an
issue with the unicode. I tried just putting in some unicode at that
low level by setting @o.value to a unicode value directly (not sure
how to get even lower level at the JSSH level) and that didn't help.

Please, if I could just get a simple yes or no about whether this is
even possible over JSSH, that would help a lot, thanks

John Kolokotronis

unread,
May 1, 2009, 8:57:00 AM5/1/09
to Watir General
I'm having similar problems working with double byte unicode, like
Japanese and yes, I'm certain the problem is with the jssh extension -
unfortunately, I don't know of any real solution and given that jssh
is abandonware, it's very hard to get any help with it on any
platform. Unicode works for me when it comes to getting values from
the browser, e.g doing this on button with a Japanese value, will
work:

@browser.button(:id, "btn_back").value.should == JapaneseString # I
have to load the string from an Excel sheet though to avoid problems,
so the assertion checks against a variable or constant that is loading
the string content from within the Excel file...

But setting a text_field with unicode, like:

@browser.text_field(:id, "whatever").set(JapaneseString) # again
loading the unicode string from Excel...

results in garbage characters... The "value" method does not work
either:

@browser.text_field(:id, "whatever").value = JapaneseString

I'm not sure jssh can even be compiled with proper unicode support,
but I just don't know enough about it to be able to try on my own...
Sorry I didn't have any real solution for you...

Regards,

John

Frank

unread,
May 14, 2009, 8:03:43 AM5/14/09
to Watir General
Hallo,

with the following code i got i working on Windows with IE and Firefox
(for Linux you might need to omit or change the conversion to a
different encoding than CP1252).
The first part i got from the other thread "Watir utf-8 (japnese)
support".
It might not work for Japanese strings, because the Windows encoding
does not contain these characters, but for European characters its
fine.
The additional elements (dd, dt, dl, strong) might be useful for you.

Regards,
Frank

# set encoding
$KCODE = "u"
WIN32OLE.codepage = WIN32OLE::CP_UTF8

require 'iconv'

module FireWatir
class DD < NonControlElement
TAG='DD'
end
class DL < NonControlElement
TAG='DL'
end
class DT < NonControlElement
TAG='DT'
end
class STRONG < NonControlElement
TAG='STRONG'
end
class TextField
def doKeyPress( value )
# do not ask me why
value = Iconv.conv('CP1252', 'UTF-8', value)
@o.value = value
fire_key_events
end
end
end

Felipe Knorr Kuhn

unread,
May 28, 2009, 1:14:59 PM5/28/09
to watir-...@googlegroups.com
Hello Frank,

I was having the same problem with portuguese characters and your code
solved all issues :)

Thanks for sharing.

FK

2009/5/14 Frank <fsch...@web.de>:

John Kolokotronis

unread,
May 29, 2009, 5:53:37 AM5/29/09
to Watir General
Thanks Frank, it's an interesting approach and does work well for
European languages. Japanese unfortunately still ends up as garbage,
even if you change the code page that iconv is converting from to
CP932, which should provide proper Japanese support under Windows. No
joy though :(.

Regards,

John
Reply all
Reply to author
Forward
0 new messages