Parsing a UTF-16LE file line by line, BUG?
pineapple via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 6 02:33:59 PST 2017
On Friday, 6 January 2017 at 06:24:12 UTC, rumbu wrote:
>>
>> I'm not sure if this works quite as intended, but I was at
>> least able to produce a UTF-16 decode error rather than a
>> UTF-8 decode error by setting the file orientation before
>> reading it.
>>
>> import std.stdio;
>> import core.stdc.wchar_ : fwide;
>> void main(){
>> auto file = File("UTF-16LE encoded file.txt");
>> fwide(file.getFP(), 1);
>> foreach(line; file.byLine){
>> writeln(file.readln);
>> }
>> }
>
> fwide is not implemented in Windows:
> https://msdn.microsoft.com/en-us/library/aa985619.aspx
That's odd. It was on Windows 7 64-bit that I put together and
tested that example, and calling fwide definitely had an effect
on program behavior.
More information about the Digitalmars-d-learn
mailing list