in reply to Re: Encoding Problem
in thread Encoding Problem

Thanks, I did not know that.

However, I tried to decode cp1254 encoded data with iso-8859-9, it gave me garbled text. I have tried it again, and it works, you are right. I mixed encodings or files when trying I guess.(lots of files and encodings etc) Sorry for that really.

So, I guess I should have not blamed Encode::Guess as well. :)

Thanks again,

Replies are listed 'Best First'.
Re^3: Encoding Problem
by graff (Chancellor) on Nov 14, 2009 at 18:08 UTC
    I tried to decode cp1254 encoded data with iso-8859-9, it gave me garbled text.

    If you had been asking for errors or warnings from Encode, it would have given you those as well.

    Make sure you understand the "superset/subset" relation: cp1254 is a superset of 8859-9 (8859-9 is a subset of cp1254), which means that treating cp1254 data as if it were 8859-9 data is likely to fail, whereas treating 8859-9 data as if it were cp1254 will not fail.

    And yes, Encode::Guess was apparently doing the right thing and giving you the correct answer, if the text you gave it happened to actually be 8859-9 (because such text could also be cp1254). But if you gave it single-byte-per-character text that included a lot of bytes in the 0x80-0x9f range, and it said "this could be 8859-9", I would call that a disappointing mistake.