Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Usage of

Moderators: larsivi kris

Posted: 12/04/08 12:37:52

While porting some DFL examples to Tango I came across - very nice.

I read a file like

scope uf = new UnicodeFile!(char) ("filename", Encoding.Unknown);
char content[] =;
Encoding encoding = uf.encoding;

After that, encoding is automagically set to e.g. Encoding.UTF_8N. When writing back the file, I would like to write a UTF-BOM only if there was an UTF-BOM in the original file.

My question is: Is there an easy way to find out, whether there had been an UTF-BOM in the file? The only way I found was to compare cast (ubyte) content.length against "filename".fileSize, but this seems ugly.

Author Message

Posted: 12/04/08 17:15:47

next release :)

Posted: 12/06/08 15:03:00

aka trunk 4148 - thank you :)

So BomSniffer?.encoded() tells me what I want to know.

But UnicodeFile?.bom is a private member, so I can't access Could you please allow access to BomSniffer?.encoded() via UnicodeFile? e.g. make UnicodeFile?.bom public (would also allow to actually retrieve signature() which might be useful) or propagate method encoded to UnicodeFile? or even add an optional out parameter to UnicodeFile?.read (orthogonal to write)?

Posted: 12/06/08 16:51:06

that's what I meant about next release :)

Posted: 12/07/08 14:57:08

Sorry, I didn't mean to put pressure on you.

Btw - Are there plans for a next release? Dominik was three months after Jeff and you can see a lot of activity in Trac lately.

Not wanting to put pressure on you as a matter of course ;-)

Posted: 12/07/08 15:04:09

Soon ... there are a few things that needs to be done first though - and we're somewhat busy.