Name: uniEncode

Type: function

Syntax: the uniEncode of <stringToEncode> 

Syntax: uniEncode(<stringToEncode> [, <language>])

Summary: Converts a <string> from single-byte text to <Unicode>.

Introduced: 1.0

OS: mac,windows,linux,ios,android

Platforms: desktop,server,web,mobile

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

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

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

Parameters:
stringToEncode (string): 
language (enum): 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"
stringToDecode (string): any string, or expression that evaluates to a string.

The result: As of LiveCode 7.0 the uniEncode function has been deprecated. It will continue to work as in previous versions but shoud not be used in new code 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 functions is only useful in combination with the also-deprecated uniDecode function and unicodeText field property.

Returns:
The <uniEncode> <function> <return|returns> a <Unicode> <string>.
If you don't specify a <language>, the <string> has each <character> of <stringToEncode> either followed or led (depending on <platform>) by a <null> <character>.

If a <language> is specified, the <uniEncode> <function> returns the <Unicode> equivalent of the <stringToEncode>, assuming the appropriate single-byte encoding for the specified <language>.

Description:
Use the <uniEncode> <function(control_st)> to convert single-byte characters to double-byte characters.

>*Important:* 

The <uniEncode> <function(control_st)> is the <inverse> of the <uniDecode> <function(control_st)> 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> <function(glossary)|functions>. You cannot set an <object|object's> <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|object's> <textFont>.

>*Important:* The <format> produced by the <uniEncode> <function(control_st)> is processor-dependent. On "big-endian" processors, where the first <byte> is least significant (such as Intel and Alpha processors), the <uniEncode> <function(control_st)> 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(control_st)> 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(control_st)> 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(control_st)> simply added a <null> <byte>.

Changes:
The ability to encode text in Polish was added in version 2.1.1.

References: textFont (property), unicodeTitle (property), object (object), string (keyword), inverse (keyword), character (keyword), null (constant), uniDecode (function), format (function), platform (function), property (glossary), Unicode (glossary), function (glossary), byte (glossary), return (glossary), function (control_st)
