Character Case Mappings; Concatenating String; Converting Between Widechar And Char; Using Format - AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

Character Case Mappings

Converting between upper and lower case is accomplished by using the Unicode.org character database
to determine the mapping between upper case and lower case characters. Not all Unicode characters have
an upper or lower case equivalent; these characters will not be affected by WC_UPPER_STRING and
WC_LOWER_STRING. Only the characters defined by Unicode.org as having an upper or lower case
mapping are affected by these functions. For more information on Unicode character conversion, see the
Unicode.org character conversion FAQ.

Concatenating String

Unicode strings and WIDECHAR array cannot be concatenated using the same syntax that ASCII
strings use. In NetLinx, string expressions are enclosed in double quotes and can only contain 8-bit
strings. To concatenate Unicode strings and WIDECHAR arrays, you must use the
WC_CONCAT_STRING function:
wcMyString = WC_CONCAT_STRING(_WC('First name'),_WC(' SurName'))
If you attempt to concatenate Unicode strings or WIDECHAR arrays using NetLinx string expressions,
expect data loss.

Converting between WIDECHAR and CHAR

On occasion, you may need to convert a CHAR array to a WIDECHAR array or a WIDECHAR array to
a CHAR array. The CH_TO_WC and WC_TO_CH functions can be used to accomplish these
conversions. For example:
wcMyString = CH_TO_WC('Any ASCII string')
wcMyString = CH_TO_WC(cMyString)
cMyString = WC_TO_CH(_WC('Any Unicode string'))
cMyString = WC_TO_CH (wcMyString)
When converting from WIDECHAR to CHAR, Unicode characters are converted to '?'. Any ASCII or
extended ASCII characters, i.e. 8-bit characters, contained in the WIDECHAR array will appear in the
CHAR array. Converting from CHAR to WIDECHAR never results in loss of data.

Using FORMAT

The NetLinx Unicode library does not include a Unicode compatible FORMAT function. In NetLinx, the
format function is used to convert numbers to text. To use FORMAT with Unicode string, use
FORMAT to convert the number to a CHAR array and then use CH_TO_WC and
WC_CONCAT_STRING to combine the result with an existing WIDECHAR array. The following two
syntaxes are functionality equivalent:
fTemperature = 98.652
cMyString = FORMAT('The current temperature is %3.2f',fTemperature)
fTemperature = 98.652
cTempString = FORMAT('%3.2f',fTemperature)
wcMyString = _WC('The current temperature is ')
wcMyString = WC_CONCAT_STRING(wcMyString,CH_TO_WC(cTempString))
NetLinx Programming Language Reference Guide
NetLinx UniCode Functions
185

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Netlinx studio 2

Table of Contents