uniDecode

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

Converts a string from Unicode to single-byte text.

Introduced1.0
Changes

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

Deprecated7.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
stringToDecode

any string, or expression that evaluates to a string.

languageANSI: synonym for "English"
Arabic:
Bulgarian:
Chinese:
English: synonym for "ANSI"
Greek:
Hebrew:
Japanese: (Shift-JIS)
Korean:
Polish:
Roman:
Russian: (Cyrillic)
Thai:
Turkish:
SimplifiedChinese:
Unicode: (UTF-16)
UTF8:
w: synonym for "Unicode"
Example
uniDecode("A" & numToChar(zero)) -- returns "A" (on PPC)
uniDecode("ABCDE") -- returns "BD" (on Intel)
uniDecode(field "JIS Input","Japanese") -- converts to JIS
Values
NameTypeDescription
return

If you don't specify a language, the uniDecode function returns the stringToDecode, with every second byte removed. If a language is specified, the uniDecode function encodes the stringToDecode into single-byte text, using the appropriate method for the specified language.

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

Tagstext processing