Hi,
In LC 7.x, where Unicode is baked in to LC, is it still necessary to encode text from a LC field when it is being exported to a text file? (Text could be from any language.)
I ask because I read a comment by one of the LC developers that "any time you do I/O to a file or socket, you should say what encoding you want..."
Also, if the answer is "yes", which is better to use, UTF-8 or UTF-16?
Thanks,
Tom Bodine
Unicode - Encode LC field for export to txt?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Mon Jul 06, 2009 4:53 am
- Location: Bamboo River
Re: Unicode - Encode LC field for export to txt?
Tom
Yes it is necessary. I'm not sure how text is stored within fields and variables in LiveCode but it will either be in UTF-16 or a clever scheme which uses either 8, 16 or 32 bits per character (like Python). If you always encode text before doing any I/O as suggested, you don't need to worry how LiveCode stores text internally, you can let LiveCode worry about that.
Personally, I think it is best to opt for UTF-8 as it has the advantage of a single form whereas UTF-16 comes in two flavours, little endian and big endian. UTF-8 is the simpler option and is the default in most, if not all web browsers.
Hope this helps.
Peter
Yes it is necessary. I'm not sure how text is stored within fields and variables in LiveCode but it will either be in UTF-16 or a clever scheme which uses either 8, 16 or 32 bits per character (like Python). If you always encode text before doing any I/O as suggested, you don't need to worry how LiveCode stores text internally, you can let LiveCode worry about that.
Personally, I think it is best to opt for UTF-8 as it has the advantage of a single form whereas UTF-16 comes in two flavours, little endian and big endian. UTF-8 is the simpler option and is the default in most, if not all web browsers.
Hope this helps.
Peter
Re: Unicode - Encode LC field for export to txt?
Thanks Peter!
-- Tom
-- Tom