in reply to string mis-match?

OK, I've made some progress... it seems perl is doing what I expect it to i.e use utf-8 when I populate a strin...

So a £ sign is represented by x'c2a3 (U+00A3), a 2-byte code.

But SOAP is sending in a single-byte x'a3 - which is the ASCII code for a £

My question has therefore evolved into "How do I tell SOAP to send utf-8 to me OR how do I use perl to convert to utf-8?"

(I have tried using Encode's 'decode_utf8' on the string received from SOAP but it didn't make any differnece that I could see...)

well, it's progress Jim, but not as we know it.

Replies are listed 'Best First'.
Re^2: string mis-match?
by afoken (Chancellor) on Aug 13, 2015 at 18:07 UTC
    But SOAP is sending in a single-byte x'a3 - which is the ASCII code for a £

    ASCII codes end at 0x7F. Everything beyond that is something else. ISO-8859-1 and its superset Windows-1252 use 0xA3 to represent £. So maybe SOAP is sending data encoded in ISO-8859-1 or Windows-1252. Maybe it is a different encoding that also uses 0xA3 to represent £. https://en.wikipedia.org/wiki/ISO/IEC_8859 documents that 0xA3 represents £ in ISO-8859-1, -3, -7, -8, -9, -13, -14, and -15.

    I have tried using Encode's 'decode_utf8' on the string received from SOAP

    How do you expect that to work? Did you actually read the Encode documentation? decode_utf8() expects a UTF-8 encoded bytestream and returns a perl string. You feed it a bytestream that is encoded in ISO-8859-1, Windows-1252, or somethings else, but not UTF-8. You need a function that can decode the encoding used for the bytestream from SOAP into a perl string. That function is called decode() and unlike decode_utf8(), it also expects an encoding name. See Encode for details.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)