pr0gramista / charset_converter

Flutter platform charset converter
BSD 3-Clause "New" or "Revised" License
29 stars 22 forks source link

ISO-8859-7 specific characters are causing encoding to fail #7

Open niktses opened 4 years ago

niktses commented 4 years ago

String encoding = "ISO-8859-7"; var encoded = await CharsetConverter.encode(encoding, line.text);

No matter the encoding used i get this error on ios. Android works fine.

PlatformException(encoding_failed, Encoding failed, reason unknown, null, null)

pr0gramista commented 4 years ago

Hmm from my first tests it seems to be working 🤔

Could you provide an example line of text that you are trying to encode?

niktses commented 4 years ago

String greekText = "αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ€"; String encoding = "ISO-8859-7"; var encoded = await CharsetConverter.encode(greekText);

pr0gramista commented 4 years ago

I found that αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ works. The problem is in the Euro sign, which wasn't present on ISO-8859-7 originally (was added in 2003) and the formal version is from 1987. Some sites doesn't include the Euro sign.

x-mac-greek does encode. but Euro sign is 156, where it should be 164. Damm you Apple.

I think the only way is to actually handle those by yourself - in the end thats only 3 characters to map. I may add some code later to handle those special cases. Thanks for reaching out!