Initializing help system before first use

getcharclass

Purpose
Get character class of a symbol.
Synopsis
function getcharclass(charcode:integer):integer
function getcharclass(txt:string|text, index:integer):integer
function getcharclass(txt:string|text):integer
Arguments
txt 
A text object or a string
index 
Position of the character
charcode 
A Unicode codepoint
Return value
The character class as a bit-encoded integer or SYS_CCLASS_INVALID if the string is empty or the requested position is invalid.
Example
The following example defines a function that checks whether a text string is a valid Mosel identifier:
function ident_valid(id:text):boolean
 returned:=
    id.size>0 and
    bittest(getcharclass(id),
        SYS_CCLASS_ALPHA+SYS_CCLASS_USCORE+SYS_CCLASS_NOASCII)<>0 and
    and(i in 2..id.size) bittest(getcharclass(id,i),
        SYS_CCLASS_ALPHA+SYS_CCLASS_USCORE+SYS_CCLASS_NOASCII+SYS_CCLASS_DIGIT)<>0
end-function
Further information
1. The returned class may include any of the following components:
SYS_CCLASS_ALPHA 
Ascii alphabetic (A-Z,a-z)
SYS_CCLASS_DIGIT 
Digit (0-9)
SYS_CCLASS_HEXLET 
Hexadecimal letter (A-F,a-f)
SYS_CCLASS_SPACE 
Space (\t,\n,\v,\f,\r, )
SYS_CCLASS_USCORE 
Underscore (_)
SYS_CCLASS_SGLQ 
Single quote (')
SYS_CCLASS_NOASCII 
Non ascii character (codepoint is greater than 127)
SYS_CCLASS_SPEC 
Special character (codepoints 0-31,127)
SYS_CCLASS_NQSAF 
Symbol exported without quoting in data files (+,-,.,~,_)
SYS_CCLASS_DQESC 
Symbol requiring escaping in double quoted strings (",\)

2. The third form of the function will return the character class of the first symbol of the string or -1 if the string is empty.
Related topics
Module

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.