Using BOM to auto-detect file encoding

Kai Meyer kai at unixlords.com
Tue Apr 9 09:25:17 PDT 2013


I would like to know if there exists a 'stream' or 'file' class 
that is able to take a text file with a correct BOM, and an 
'ouput' utf encoding. It want it to be capable of detecting the 
'input' stream utf encoding by using the BOM, and do the encoding 
for me on the way out in the specified 'output' utf encoding.

Right now I am using std.stream.File (which I know is going the 
way of all the earth soon) and manually parsing the BOM myself to 
then choose whether I call 'readLine' or 'readLineW', and then 
subsequently calling 'toUTF8' after that.

It just seems like something like this would be nice to have in 
phobos if it's not already there.


More information about the Digitalmars-d-learn mailing list