SaveWideStringToFileWithBOM
SaveWideStringToFileWithBOM saves the string given by aContents as a file on disk named as specified by aFileName.
SaveWideStringToFileWithBOM handles unicode characters.
What makes this function different from SaveWideStringToFile, is that it saves the file taking byte order into account by using BOM - an acronym for Byte Order Marks.
This function processes by little-endian with the least-significant byte at the smallest memory address, meaning that the first byte will be in memory address location 1, the second byte in memory location 2, the third in memory location 3, and so on.
To save a file ignoring BOM, please refer to SaveWideStringToFile.
If a file with aFileName already exists, then it will be overwritten - if attributes and permissions allow. If permissions and attributes do not allow it to be overwritten, then an exception error will be encountered.
Declaration: Procedure SaveWideStringToFileWithBOM(const aContents : string; const aFileName : string);
An example to save a text file that contains several unicode characters, to simply illustrate the function syntax and its use.
procedure
OnMapEvent(
var
Value:Variant);
var
vData :
string
;
begin
vData :=
'AaBbÖP€CcDd €Ö£PÆ Ajkshdsdfhl adf jalsd fj;ao sdfj ;sod;as Æ8™€çZÐ text with lots of unicode.'
;
SaveWideStringToFileWithBOM(vData,
'c:\Temp\BOMTodayTestWS.txt'
);
end
;