As officially suggested, working with outside files, the textEncode () and textDecode () functions must be used.
After some testing, I do not know how to solve my current text encoding and decoding problem.
As a text editor, I am using the latest version of Notepad++.
Downloading a text file from Google (exported contacts), the original text file "google.csv" is encoded in "UCS-2 LE BOM". I do not know what this actually means, but my usual textDecode ( text , "UTF-8" ) does not work here for any nonstandard characters.
The text to test:
The Russian text is not supported in "ANSI" for West-European languages and will not show.Программируем
Bewußt über das Thema diskutieren
- Reading this Google-encoded file using UTF-8 will neither show German special "Umlaute" nor the Russian text (which appears as question marks).
- Reading it without decoding correctly shows European and German characters, but no Russian characters
- Converting the file using Notepad++ to UTF-8 works ok. Then also textDecode(text, "UTF-8") will work correctly.
Is there a way that we could convert a text file from such format "UCS-2 LE BOM" to "UTF-8" using LiveCode? Unfortunately, I have not been able doing this.
To read the file, I tried two ways:
Code: Select all
...
open file tFileName
read from file tFileName until eof -- end of file
close file tFileName
put textDecode ( it , "UTF-8" ) into field "test"
...
Code: Select all
...
get URL("file:"&tFileName)
put textDecode ( it , "UTF-8" ) into field "test"
...
Now a side question: What is better, using "reading from file" or the shorter "URL" syntax?