uniEncode

Converts a string from single-byte text to Unicode.

# Metadata

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

# Syntax

the uniEncode of stringToEncode

# Params

- stringToEncode : any string, or expression that evaluates to a string. - language : one of the following - "ANSI" (synonym for "English" - "Arabic" - "Bulgarian" - "Chinese" - "English" - "Greek" - "Hebrew" - "Japanese" (Shift-JIS) - "Korean" - "Polish" - "Roman" - "Russian" (Cyrillic) - "Thai" - "Turkish" - "SimplifiedChinese" - "Unicode" (UTF-16) - "UTF8" - "w" (synonym for "Unicode")

# Examples

uniEncode("AB") -- returns "A",null,"B",null (on Intel)

uniEncode("AB") -- returns null,"A",null,"B" (on PPC)

uniEncode(inputText,"Japanese") -- converts Shift-JIS to Unicode

# Description

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

>*Important:* As of LiveCode 7.0 the uniEncode 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 uniDecode > function and unicodeText field property. Instead, for converting > text between encodings, use the textEncode and textDecode > functions.

>*Important:* > The uniEncode function is the inverse of the > uniDecode function and inserts null bytes for > Unicode compatibility. In other words, it turns single-byte > characters into their double-byte equivalent.

>*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 produced by the uniEncode > function is processor-dependent. On "big-endian" > processors, where the first byte is least significant (such as Intel > and Alpha processors), the uniEncode function > adds the null byte after each character. On "little-endian" > processors, where the last byte is least significant (such as > PowerPC processors), the uniEncode function > adds the null byte before each character.

The ability to handle double-byte characters on "little-endian" processors was added in version 2.0. In previous versions, the uniEncode function always added the null byte after the character, regardless of platform.

The ability to convert language-specific encodings into Unicode text was added in version 2.0. In previous versions, the uniEncode function simply added a null byte.

# Tags

# See

- **keyword:** character, inverse, string - **constant:** null - **property:** textFont, unicodeTitle - **function:** format, platform, textDecode, textEncode, uniDecode - **glossary:** byte, function, object, property, return, Unicode - **control structure:** function