Reference > Functions reference > Container functions > TextEncode
 

TextEncode

Returns a text file as container data from text using the specified character encoding and line endings.

Format 

TextEncode(text;encoding;lineEndings)

Parameters 

text - any text expression or field.

encoding - the name of the character encoding to use (see below).

lineEndings - a number that specifies the line endings to use (see below). If not specified, line endings are left unchanged.

Data type returned 

container

Originated in 

FileMaker Pro 16.0

Description 

For the encoding parameter, use one of the following names to specify the character encoding. If you use no value or an unrecognized value, this function returns "?".

 

encoding

Encodes text using

utf-8

Unicode

iso-8859-1

Latin 1

windows-1251

Cyrillic

shift_jis

Japanese

windows-1252

Windows

gb18030

Simplified Chinese

euc-kr

Korean

big5

Traditional Chinese

macintosh

Mac Roman

For the lineEndings parameter, use one of the following values to specify the line endings to use. If you use an unrecognized value, line endings are unchanged.

 

lineEndings

Changes line endings to

1

Unchanged

2

Carriage return (legacy Mac standard)

3

Line feed (modern Mac, Unix/Linux standard)

4

Carriage return followed by a line feed (Windows standard)

Notes 

This function is not supported in runtime solutions and returns "?".

Example 1 

Returns a text file as container data from a text field using Japanese character encoding and leaves line endings unchanged.

TextEncode ( table::text ; "shift_jis" ; 1 )

Example 2 

Converts the contents of a text field to ISO-8859-1 character encoding and Windows line endings, then exports the resulting container field as a text file.

Set Field [ table::container ; TextEncode ( table::text ; "iso-8859-1" ; 4 ) ]
Export Field Contents [ table::container ; "output.txt" ; Create directories: Off]

Related topics 

Functions reference (category list)

Functions reference (alphabetical list)

About formulas

About functions

Defining calculation fields

Using operators in formulas