Ord

Description:

Returns the numeric code of a character in a string.

Syntax:

result = ord(string [, position])

where:

string
the string.
position
the position of the character in the string.

Return Value:

The order code integer representation of the character at the specified position in the string. This will be the ASCII, EBCDIC, Unicode or another value depending on the system, code page in use and character set.

Remarks:

The actual value returned for any character depends on several factors.

Windows supports ASCII, UTF-8 and UTF-16. Linux supports ASCII, UTF-8 and UTF-32. IBM mainframes support EBCDIC, UTF-8 and UTF-16. It is possible that the compiler will be ported to another system that supports a different encoding.

In Windows, if the string is declared as a simple string, the value could be ASCII or UTF-8. If the string is declared as a wide character string, the value could be ASCII or UTF-16.

In DOS, wide character strings are not supported but 8-bit ASCII is. This can also apply to the windows command prompt. In this case the character returned depends on the code page in use, but it will always be less than 256.

This function should be used to get the numerical value of a particular character if it is required, but no assumption should be made about the actual value returned.

this function returns zero (0) if the string is empty, the position is less than one (1), or the position is greater than the number of characters in the string.

Example:

put ord("abc")           // 97
put ord("abc", 2)        // 98

wstring*20 wxstr
wxstr = "Привет мир!"
put ord(wxstr, 2)       // 1088

See Also:

Implementation Status:

LynPlex Interpreter
Implemented, but the position option is not yet supported.
Only the characters in the active code page are currently supported.
LynPlexC Compiler
Fully implemented
Characters may also be extracted from a string using the operator [] (String Index).
LynPlexS Compiler
Fully implemented
Only the characters in the active code page are currently supported.
Characters may also be extracted from a string using the operator {} (String Index).

lynplex/lp0402_ord.txt · Last modified: 2013/10/13 13:23 (external edit)