uniEncode

Typefunction
DictionaryLCS
LibraryLiveCode Script
Syntax
the uniEncode of <stringToEncode>
uniEncode(<stringToEncode> [, <language>])
Summary

Converts a string from single-byte text to Unicode.

Introduced1.0
Changes

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

The tokens uniEncode, uniDecode and unicodeText are all deprecated from version 7.0.

Deprecated7.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
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")

Example
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
Values
NameTypeDescription
return

The uniEncode function 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.

RelatedKeyword: character, inverse, string
Constant: null
Property: textFont, unicodeTitle
Function: format, platform, textDecode, textEncode, uniDecode
Glossary: byte, function, object, property, return, Unicode
Control Structure: function
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'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's 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.

Tagstext processing