[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Strings compares in UTF-8 and ANSI

pkchau

3/23/2005 6:15:00 PM

I'm grabbing strings from an IE browsers using WATIR. The text in IE
is encoded in UTF-8 and shows up correctly in a DOS prompt. I want to
do string compares between this UTF-8 string with a ANSI string from
my script. How can I convert the UTF-8 to an ANSI?
1 Answer

Carlos

3/23/2005 6:41:00 PM

0

[Peter C <pkchau@gmail.com>, 2005-03-23 19.19 CET]
> I'm grabbing strings from an IE browsers using WATIR. The text in IE
> is encoded in UTF-8 and shows up correctly in a DOS prompt. I want to
> do string compares between this UTF-8 string with a ANSI string from
> my script. How can I convert the UTF-8 to an ANSI?

I don't know what are ANSI strings. If they are 8-bit, latin-1 encoded
strings, then you can convert between them and utf8 using pack and unpack:

utf8 -> latin1: "abcd".unpack("U*").pack("C*")

latin1 -> utf8: "abcd".unpack("C*").pack("U*")

HTH