Command SET COLLATION Foundation

Selects a collation table for characters.

Syntax
SET COLLATION TO [ ASCII  | DIN | SYSTEM | ;
                   AMERICAN     | ;
                   BRITISH      | ;
                   DANISH       | ;
                   DUTCH        | ;
                   FINNISH      | ;
                   FRENCH       | ;
                   GERMAN       | ;
                   GREEK437     | ;
                   GREEK851     | ;
                   ICELANDIC850 | ;
                   ICELANDIC861 | ;
                   ITALIAN      | ;
                   NORWEGIAN    | ;
                   PORTUGUESE   | ;
                   SPANISH      | ;
                   SWEDISH        ]
Scope
thread-local
Description

The command SET COLLATION selects the collation table that defines the sorting sequence of characters. Depending on the collation table, a single character can have different weighing factors for lexical string comparisons. This is important for index creation when characters are to be sorted according to their lexical meaning instead of their ASCII value. Language-specific special characters can be sorted correctly in this way.

The country-specific collation table is selected in the file DBESYS.PRG before database engines are loaded.

SET COLLATION TO SYSTEM causes the simple comparison operators (<, <=, =, >=, >, <>) to become case insensitive in string comparisons. However, the exactly equal operator (==) remains case sensitive.

Examples
Define the sorting order of characters

// In the example, all letters are stored in an array which gets sorted 
// using ASort(). Different collation tables are used and the result is 
// displayed with Memoedit(). 

#define CRLF  Chr(13)+Chr(10) 

PROCEDURE Main 
   LOCAL aChar := {}, i, cCollation := "" 

   FOR i:=1 TO 256 
     IF IsAlpha( Chr(i) ) .AND.; 
        i <> 141                       // 141 is a soft carriage 
        AAdd( aChar, Chr(i) )          // return for Memoedit! 
     ENDIF 
   NEXT 

   SET COLLATION TO SYSTEM 
   ASort( aChar )                      // System collation table 
   cCollation := "SYSTEM:" + CRLF 
   AEval( aChar, {|c| cCollation += c } ) 

   SET COLLATION TO GERMAN 
   ASort( aChar )                      // German collation table 
   cCollation += CRLF + "GERMAN:" + CRLF 
   AEval( aChar, {|c| cCollation += c } ) 

   SET COLLATION TO SPANISH 
   ASort( aChar )                      // Spanish collation table 
   cCollation += CRLF + "SPANISH:" + CRLF 
   AEval( aChar, {|c| cCollation += c } ) 

   MemoEdit( cCollation,,,,,,, 260 ) 
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.