uniDecode

Converts a string from Unicode to single-byte text.

# Metadata

Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 1.0 Security:

# Syntax

the uniDecode of stringToDecode

# Params

- stringToDecode : any string, or expression that evaluates to a string. - language :

# Examples

uniDecode("A" & numToChar(zero)) -- returns "A" (on PPC)

uniDecode("ABCDE") -- returns "BD" (on Intel)

uniDecode(field "JIS Input","Japanese") -- converts to JIS

# Description

Use the uniDecode function to convert double-byte characters to single-byte characters.

>*Important:* As of LiveCode 7.0 the uniDecode function has been > deprecated. It will continue to work as in previous versions but > should not be used in newcode as the existing behaviour is > incompatible with the new, transparent Unicode handling (the resulting > value will be treated as binary data rather than text). This function > is only useful in combination with the also-deprecated uniEncode > function and unicodeText field property. Instead, for converting > text between encodings, use the textEncode and textDecode > functions.

The uniDecode function is the inverse of the uniEncode function and removes the null bytes inserted for Unicode compatibility. In other words, it turns double-byte characters into their closest single-byte equivalent.

If the stringToDecode contains an odd number of bytes, the last byte is ignored.

>*Note:* You can use the UTF8 encoding only with the uniDecode and > uniEncode functions. You cannot set an > object textFont property to use UTF-8. To display > Unicode text in an object, use either "Unicode" or a > language name as the second item of the object textFont.

>*Important:* The format expected by the uniDecode > function is processor-dependent. On "little-endian" processors, > where the first byte is least significant (such as Intel and Alpha > processors), the uniDecode function removes the > second byte of each character. On "big-endian" processors, where the > last byte is least significant (such as PowerPC processors), the > uniDecode function removes the first byte of > each character.

The ability to handle double-byte characters on "little-endian" processors was added in version 2.0. In previous versions, the uniDecode function always removed the second byte of each pair of bytes, regardless of platform.

The ability to convert Unicode text into language-specific encodings was added in version 2.0. In previous versions, the uniDecode function simply removed every other byte.

# Tags

# See

- **keyword:** character, characters, inverse - **constant:** null - **property:** textFont, unicodeText - **function:** format, platform, textDecode, textEncode, uniEncode - **glossary:** byte, function, object, property, return, Unicode - **control structure:** function