On Wed, 8 Jan 2014 10:19:37 -0800 (PST) Alexandru Ciprian Branescu wrote:
ACB> To be more clear, what I've done locally is to modify the header of
ACB> wxTextFile/Buffer::Write():
ACB>
ACB> bool Write(wxTextFileType typeNew = wxTextFileType_None, const wxMBConv&
ACB> conv = wxConvAuto(), const char* charBOM = NULL, size_t lengthBOM = 0);
ACB>
ACB> then at application level:
ACB>
ACB> // write the UTF-8 BOM
ACB> size_t count=0;
ACB> const char* bom( wxConvAuto::GetBOMChars( wxBOM_UTF8, &count ) );
ACB> bool ok = file.Write( wxTextFileType_None, wxMBConvUTF8(), bom, count );
ACB>
ACB> Of course, this introduces some redundancy (in theory the BOM could be
ACB> deduced from wxMBConv type) but I prefer it over nothing.
But why do you need to modify anything to do it like this? Just prepend
the BOM data to the first line... The whole point of any specific API would
be to determine the BOM to use automatically.
One thing which we could definitely improve would be to allow obtaining
the BOM bytes in a less ugly way than by using wxConvAuto::GetBOMChars()
(which was never meant to be public anyhow BTW). As previously mentioned,
any simple patches adding such an API would be welcome.