Livecode Wiki
Advertisement

Converts from binary data to text.

Built-in Function handler[]

Syntax:

textDecode(<binaryData>, <encoding>)

Examples:

textDecode("A","UTF8")
put url ("file:input.txt") into tTextToDecode
put textDecode(tTextToDecode,"ASCII") into field "input"

Converts from binary data to text.

The textDecode function takes binary data, in the specified encoding, and returns the given string as text.

It is highly recommended that any time you interface with things outside LiveCode (files, network sockets, processes, etc) that you explicitly textEncode any text you send outside LiveCode and textDecode all text received into LiveCode. If this doesn't happen, a platform-dependent encoding will be used (which normally does not support Unicode text).

It is not, in general, possible to reliably auto-detect text encodings so please check the documentation for the program you are communicating with to find out what it expects. If in doubt, try UTF-8.

Parameters:

  • binaryData: Binary data to be
  • encoding (enum): the encoding of the original data:
    • "ASCII"
    • "UTF-16"
    • "UTF-16BE"
    • "UTF-16LE"
    • "UTF-32"
    • "UTF-32BE"
    • "UTF-32LE"
    • "UTF-8"
    • "CP1252"
    • "ISO-8859-1": Linux only
    • "MacRoman": OS X only
    • "Native": ISO-8859-1 on Linux, MacRoman on OS X, CP1252 on Windows
  • Returns: Returns the binaryData as text.
Advertisement