Skip navigation links
Expressively and easily automate your text documents with TExpressive!
Expressively and easily automate your text documents with TExpressive!

File encoding

Templates are regular text documents.  There are however a couple of ways a text document can be stored (how it's characters are encoded).  The encodings TExpressive supports are ASCII, UTF8 and UTF16.  The latter three are Unicode encodings that can represent all possible international characters; ASCII however can only represent a small amount of characters.

When TExpressive writes the result of a template to file, it will use the same character encoding that was used for the template itself.  This ensures that the template's result will reflect the template's design as best as possible.  When the template is encoded in ASCII and when it includes or processes some other templates that contain characters that are not representable in ASCII, these characters cannot be represented in the template result when saved in ASCII.  In that case TExpressive will encode the result in UTF8.

You can however tell TExpressive to use a certain encoding when creating files.  The "Output" function does this via the argument "FileEncoding".  You can also specify the "/OutEncoding" option on the command line..  When the given encoding cannot represent the content then TExpressive will give an error.

TExpressive will try to detect what encoding is used when reading a file by looking for the Unicode BOM (Byte Order Mark) at the start of the file.  The BOM is a signature that tells what Unicode encoding is used in the file's content.  When no BOM is found, TExpressive assumes the file is encoded as ASCII.  So, when saving template files that contain international characters, make sure to save them in a Unicode format (UTF8 or UTF16) with a BOM.  When you must work with Unicode files without a BOM, you can tell TExpressive what encoding the file is in.  You can use the "FileEncoding" argument when using the "Input" and "Process" functions.  On the command line this is done via the "/InEncoding" option.