Strings compares in UTF-8 and ANSI

P

Peter C

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?
 
C

Carlos

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top