FutureBasic Logo

<<    Index    >> FutureBasic

ucc   function



Syntax
uniChar = ucc( cfstring [, index ] )

Description
The ucc function returns the Unicode Character Code of cfstring at the given character index. If index is not specified, the function returns the first character in cfstring.

Parameters
Parameter
Description
cfstring A CFStringRef. The string from which the unicode character is retrieved.
index Optional. The position of the character to be retrieved. Default = 0.

 
Return value
uniChar is the unicode character (unichar) at the specified index in cfstring, or zero if cfstring is NULL or index is out of bounds.

Example

CFStringRef myString = @"Hello"
unichar firstChar = ucc(myString) // returns 72 (unicode value for 'H')
unichar secondChar = ucc(myString,1) // returns 101 ('e')
unichar outOfBoundsChar = ucc(myString,10) // returns 0
myString = NULL
unichar nullChar = ucc(myString) // returns 0
Notes
• Ensure cfstring is properly initialized before calling ucc to avoid unexpected results.
• The index is zero-based, meaning the first character is at position 0.
• This function cannot extract a unichar from a pascal string. Pascal strings encode characters in one byte but unichars may need more than one byte.
• A unichar type represents a single UTF-16 code unit in an NSString. Although some characters may be represented in a single unichar, others, such as Emoji, may span multiple unichars.

See also
ucs; asc