charToNum

Typefunction
DictionaryLCS
LibraryLiveCode Script
Syntax
the charToNum of <character>
charToNum(<character>)
Summary

Returns the ASCII value of a character.

Introduced1.0
Changes

The ability to handle Unicode characters was introduced in version 2.0. In previous versions, it was not possible to pass a Unicode character to the charToNum function.

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

The character is any character or expression that evaluates to a character. If you specify a string containing more than one character, all characters but the first are ignored.

Example
charToNum("A")
charToNum("ABC")
if charToNum(nextChar) = 0 then next repeat
numToChar(charToNum("Z"))
Values
NameTypeDescription
return

The charToNum function returns an integer between zero and 255. If the useUnicode property is set to true, the charToNum function returns an integer between zero and 65535.

RelatedKeyword: inverse, character, integer
Operator: div
Property: extendKey, RTFText, HTMLText, unicodeText, useUnicode
Function: nativeCharToNum, numToCodepoint, numToChar, uniDecode, byteToNum, numToByte, mouseCharChunk, numToNativeChar, md5Digest, clickChar, format, URLDecode, codepointToNum
Glossary: property, numeric, ASCII, return, Windows, character set, Mac OS, ISO 8859, Unix
Control Structure: function
Description

Use the charToNum function to rank characters in their numerical order.

Important: As of version 7.0 the numToChar and charToNum functions have been deprecated. They will continue to work as in previous versions but should not be used with Unicode text as unexpected results may occur. If working with Unicode text use the numToCodepoint and codepointToNum functions, for native text use numToNativeChar and nativeCharToNum functions. If working with binary data use the numToByte and byteToNum functions.

The charToNum function is the inverse of the numToChar function.

For special characters (those typed using the Option key or Alt key), the value returned by the charToNum function depends on the character set currently in use. On Mac OS systems this is normally the Macintosh character set; on Unix systems, this is normally ISO 8859; on Windows systems, this is usually Code Page 1252, a variant of ISO 8859.

If the useUnicode property is set to true, you can specify a double-byte character. If the useUnicode is false and you specify a double-byte character, the charToNum function returns the numeric value of the character div 256.

Tagstext processing