Error getting tags :
error 404Error getting tags :
error 404 uniEncode | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
uniEncode
Basics
Expander triangle
Type
Function
Syntax

the uniEncode of stringToEncode uniEncode(stringToEncode[,language])

Introduced
1.0
Changed
2.1.1
Environment
Desktop, Web and Server
Platform Support
MacOS,Mac OS X,Windows,Linux
Security
None required
Summary
Converts a string from single-byte text to 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

Additional Comments
Expander triangle

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

Parameters:

The stringToEncode is any string, or expression that evaluates to a string.

The language is one of the following:

* ANSI (synonym for "English")

* Arabic

* Bulgarian

* Chinese

* English

* Greek

* Hebrew

* Japanese (Shift-JIS)

* Korean

* Polish

* Roman

* Russian (Cyrillic)

* Thai

* Turkish

* SimpleChinese (Simplified Chinese)

* Ukrainian

* Unicode (UTF-16)

* UTF8

* w (synonym for "Unicode")

Value:

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.

Comments:

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 uniEncodefunctions. You cannot set an object'stextFontproperty 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'stextFont.

Important! The format produced by the uniEncodefunction is processor-dependent. On "big-endian" processors, where the first byte is least significant (such as Intel and Alpha processors), the uniEncodefunction adds the nullbyte after each character. On "little-endian" processors, where the last byte is least significant (such as PowerPC processors), the uniEncodefunction adds the nullbyte before each character.

Changes to Revolution:

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

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.

User Comments
Expander triangle
User thumbnail
Devin Asay
StarStarStarStarStar
Apr 9, 2009
Here is how to read in and display UTF-8 text in a Rev field:


put url ("binfile:/path/to/file/myUniText.ut8") into tRawTxt
set the unicodeText of fld "display" to uniEncode(tRawTxt,"UTF8")

User thumbnail
rodney@oceanbrowser.com
StarStarStarStarStar
Jun 4, 2010
If you are reading in a text file (for example) which contains high ascii values (such as curly quotes - numToChar(210) ) you will find that these are displayed as garbage in the variable watcher, or if you set directly to the field contents.
The solution is to encode and decode the content:
#tData contains your data read in from file put uniDecode(uniEncode(tData, "UTF8")) into tData
(All credit to Dave Cragg and Devin Assay for this tip)