I know how to read a file with Haxe by using sys.io.File.read (compare Reading lines from a file in Haxe and I also know that the sys module is not available for each target). However how can I tell sys.io.File.read that my text file is encoded via a certain encoding (e.g. UTF-16, UTF-8, ISO-8859-1, ...)?
相关问题
- ruby 1.9 wrong file encoding on windows
- WebElement.getText() function and utf8
- Does specifying the encoding in javac yield the sa
- FlashDevelop Haxe (Flash) debugger
- How to check if a string contain only UTF-8 charac
相关文章
- Base64 Encoding: Illegal base64 character 3c
- read xml in UTF-8 in scala
- Does the img tag's alt attribute require encod
- WebClient DownloadString UTF-8 not displaying inte
- Is there a such a thing like “user-defined encodin
- German Umlauts in strftime date-formatting - corre
- C# method to do URL encoding?
- Insert special character using :before pseudo clas
There is no way to do this at
File
-level, but you can encode / decode theString
after reading the file. For instance,Utf8.encode()
will convert a ISO-8859-1 string to a UTF-8 string:The standard library currently doesn't support UTF-16, but it's coming in Haxe 4. In the meantime, you can use libraries such as unifill for that.
Btw, if you don't need to read a file line-by-line,
File.getContent()
is much more convenient than theFile.read()
-approach you linked.