Function LocaleConfigure() Foundation

Configures data used by internal locale subsystems

Syntax
LocaleConfigure( <nDefine>, [<xNewConfigData>] ) --> xOldConfigData
Scope
thread-local
Parameters
<nDefine>
<nDefine> is one of the LOCALE_.. #define constants. See below.
<xNewConfigData>
If passed, <xNewConfigData> replaces the previous set of data for that locale. It must be of the same type and size as the previous data for that setting.
Return

LocaleConfigure() returns the current data for that locale subsystem.

Description

LocaleConfigure() can be used to reconfigure internal subsystems which have a locale (nationalized) character set. This might be required if the Xbase++ runtime has to be localized, or deals with multiple-language versions in one application.

The settings remain active until the thread has terminated, or one of the commands that also change these tables is called. This can be either SET COLLATION or SET CHARSET .

The effect of the changes are thread-local but will change the behaviour of various functions and automatic operations. Changing these values can confuse the application's logic if the influences are not considered in all places of the program. As an example, if an index using Upper() in its expression is created based on a changed LOCALE_TO_UPPER table, then this index will be unusable outside of that program because Upper() behaves differently depending on different settings.

The following table explains valid values for parameter<nDefine>and their effect:

Possible values for <nDefine> and meaning
Constant Type/Size Description
LOCALE_COLLATION C, 256 Sort order for character strings, used by all comparison operations, also by functions that implicitely compare strings like ASort().
LOCALE_CHAR_TYPE C, 256 Character type table used by IsAlpha(), IsDigit() must be interpreted as a string of 8bit Bitfields
Bit 1 = IsDigit()
Bit 2 = IsAlpha()
LOCALE_TO_UPPER C, 256 Corresponding upper case characters for a given character, used by Upper() and IsUpper()
LOCALE_TO_LOWER C, 256 Corresponding lower case characters for a given character, used by Lower() and IsLower()
LOCALE_ANSI_TO_OEM C, 256 Conversion table used for ANSI to OEM transformations, like ConvToOemCp(), and all automatic transformations, like reading a FOXDBF table stored as ANSI when SET CHARSET is set to OEM
LOCALE_OEM_TO_ANSI C, 256 Conversion table used for OEM to ANSI, see above.

Examples
Manipulating the character type data for IsAlpha()
// In the example, the property "IsAlpha()" is 
// manipulated for a given character. After that, 
// the function IsAlpha() will return .T. for that 
// character. 

#include "Nls.ch" 

PROCEDURE Main 
   LOCAL nCodePoint := 1  // the code point to be altered 
   LOCAL cTypes, nVal 

   // retrieve current settings 
   cTypes := LocaleConfigure( LOCALE_CHAR_TYPE ) 

   // check if nCodePoint is already considered 
   // as an alpha character 
   // attention! code point range is 0..255 but 
   // element access from 1..256! 
   nVal := Asc( cTypes[nCodePoint+1] ) 

   // bit 2 tells the state of IsAlpha() 
   IF !nVal[2] 
      // no, it is not, turn it on now 
      nVal[2] := .T. 
      cTypes[nCodePoint+1] :=Chr( nVal ) 

      // set the new value 
      LocaleConfigure( LOCALE_CHAR_TYPE, cTypes ) 
   ENDIF 

   // Now check if it is working 
   ? IsAlpha( Chr(nCodePoint) ) 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.