KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: String Types, Constants, and Unicode Mode
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Mac & Win
Published On: October 13, 2015

Be careful when using Unicode mode with String type variables. When Unicode mode is active String types are the same as their respective Text types, however the constants do not change to reflect this behavior. Examples are shown below.

In compatibility mode:

SET DATABASE PARAMETER(41;0)
$unicodeMode:=Get database parameter(41)

C_TEXT($textVar)
_o_C_STRING(30;$stringVar)
ARRAY TEXT($textArray;0)
_o_ARRAY STRING(30;$stringArray;0)

$textVar_Type:=Type($textVar)
$stringVar_Type:=Type($stringVar)
$textArray_Type:=Type($TextArray)
$stringArray_Type:=Type($StringArray)

Is text
Is string var
Text array
String array

TRACE



As seen, the variables' types and constansts match each other as expected when unicode mode is disabled.

In unicode mode:
SET DATABASE PARAMETER(41;1)
$unicodeMode:=Get database parameter(41)

C_TEXT($textVar)
_o_C_STRING(30;$stringVar)
ARRAY TEXT($textArray;0)
_o_ARRAY STRING(30;$stringArray;0)

$textVar_Type:=Type($textVar)
$stringVar_Type:=Type($stringVar)
$textArray_Type:=Type($TextArray)
$stringArray_Type:=Type($StringArray)

Is text
Is string var
Text array
String array

TRACE



However, with unicode mode enabled, String types are changed to the same as Array types, and do not match their constants.