Tudor Girba wrote:
Hi Nicolas,
Thanks for the tips.
I am a bit alien to the topic of encodings, so I will ask a couple of silly questions.
How exactly do I deal with another encoding? For example, why does this work with Utf-8, and what would I do if I encountered another encoding?
Or more general, how can I find out what kind of converter I need for a given file?
Welcome to a world full of shit. Executive summary: you're fucked. To read a file as a String instead of a ByteArray you need a way to map bytes to characters aka the file encoding. The problem is there is no way of knowing what the file encoding is. There just isn't because the operating system doesn't know and it does all the file handling. The only thing that you can know is when a file is not UTF-8. That is when you treat it as UTF-8 and get an UTF-8 error. You can pretend the problem doesn't exist and just use a random encoding aka the platform default encoding. That would work if all your files were are created on your computer and all your programs used the platform default encoding. E.g. you don't download stuff from the internet or copy stuff off storage media (USB sticks, CDs, DVDs, ...). The funny thing is that XML partially solves the problem because the encoding can be put into the preamble. In fact it should if the file is not ASCII. You can make a guess whether Yaxo supports binary input and detecting the encoding either from the BOM or the preamble. Cheers Philippe