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

On May 1, 2:57 pm, John Kolokotronis <[email protected]> wrote:
> 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
>
> On May 1, 12:54 am, Stacia <[email protected]> wrote:
>
> > 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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to