---
url: >-
  /statelake/scripting-reference/functions-and-procedures/file-functions/savewidestringtofilewithbombe.md
---

# SaveWideStringToFileWithBOMBE

**SaveWideStringToFileWithBOMBE** saves the string given by **aContents** as a file on disk named as specified by **aFileName**.

**SaveWideStringToFileWithBOMBE** handles unicode characters.

The function is similar to **SaveWideStringToFileWithBOM**, because the function enables the file to be saved taking *byte order* into account by using **BOM** - an acronym for **Byte Order Marks**.

However, this function processes by *big-endian* with the most-significant byte at the smallest memory address. This means that if two bytes are used, then the first byte will be pushed into memory address location 2, and the second byte will reside in memory location 1.

Pease also see [SaveWideStringToFileWithBOM](/statelake/scripting-reference/functions-and-procedures/file-functions/savewidestringtofilewithbom).

To save a file ignoring BOM, please refer to [SaveWideStringToFile](/statelake/scripting-reference/functions-and-procedures/file-functions/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 SaveWideStringToFileWithBOMBE(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.

```pascal
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.';
  SaveWideStringToFileWithBOMBE(vData, 'c:\Temp\BOMBETodayTestWS.txt');
end;
```
