reading UTF-8 formated file into dynamic array

Carlos Santander csantander619 at
Tue Jul 24 10:42:29 PDT 2007

thofis escribió:
> Hi,
> I try to read a text file into a dynamic array but got stucked with non
> ASCII characters. While trying I looked at the word count example.
> (
> Basicly there's used:
> char[] input;
> // read file into input[]
> input = cast(char[])[i]);
> But it seems that this casting does not result in proper filling of
> _input_. Any non ACSII character is splited into multiple characters.

That's just the nature of UTF-8 and how it's handled in D.

> (BOM is also contained in _input_.)
> So..., how I get a UTF-8 file properly mapped into an dynamic array?
> Bye contains a BOM Stream class or some such. Try that instead of

Carlos Santander Bernal

More information about the Digitalmars-d-learn mailing list