CharVal() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns the character code for the first character in a string expression. This function is the Unicode corollary of the Asc() function, so that the return value maps to the Unicode character set encoding of the string expression (string_expr), rather than the system character set mapping. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

CharVal( string_expr ) 

string_expr is a string expression.

Return Value

Integer

Description

The CharVal() function returns the character code representing the first character in the string specified by the string expression, string_expr. If string_expr is a null string, then CharVal() returns a value of zero.

Note: Except for the character encoding mapping, the usage and behavior of CharVal() is the same as Asc() function.

CharVal() is only applicable for Unicode versions of MapInfoPro and returns a value of zero for non-Unicode versions of MapInfo Pro.

Example

The following example displays the corresponding Unicode encoding for the character, which will be 8364, 1587, and 24330:

Dim code As SmallInt
code = CharVal("€")
code = CharVal("س")
code = CharVal("弊")

See Also:

Asc() function, ChrU$() function, Character Code Table Definitions