xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_SetCodePage()

Queries or changes the current code page.

Syntax

HB_SetCodePage( [<cCodePageID>] ) --> cOldCodePageID

Arguments

<cCodePageID>
This is a character string identifying the code page to select as current (see table below).

Return

The function returns a character string identifying the code page selected before the function is called.

Description

Function HB_SetCodePage() queries and optionally changes the current code page used for character strings. Code pages differ by the character set (ANSI/OEM) and national language. They define the "sorting weight" of characters in the national alphabet.

By default, code page 437 for the English language is selected. In order to change the code page to a different character set, the corresponding module must be linked. That is, the symbolic names of the code pages to be available at runtime must be REQUESTed.

When the code page module is linked, the code page can be changed at runtime by passing the code page identifier <cCodePageID> to HB_SetCodePage(). The following table lists the REQUEST symbols and code page identifiers available in xHarbour.

Code page support in xHarbour
Language nameCode pageREQUEST symbol<cCodePageID>Source file
BulgarianWindows-1251HB_CODEPAGE_BG1251"BG1251"cpbgwin.c
BulgarianMIKHB_CODEPAGE_BGMIK"BGMIK"cpbgmik.c
Croatien1250HB_CODEPAGE_HR1250"HR1250"cphr1250.c
Croatien437HB_CODEPAGE_HR437"HR437"cphr437.c
Croatien852HB_CODEPAGE_HR852"HR852"cphr852.c
English437none"EN"cp_tpl.c
French850HB_CODEPAGE_FR"FR"cpfrdos.c
German850HB_CODEPAGE_DE"DE"cpgedos.c
GermanISO-8859-1HB_CODEPAGE_DEWIN"DEWIN"cpgewin.c
Greek (Dos)737HB_CODEPAGE_EL"EL"cpeldos.c
Greek WINANSI (1253)HB_CODEPAGE_ELWIN"ELWIN"cpelwin.c
Hungarian852HB_CODEPAGE_HU852"HU852"cphu852.c
HungarianWindows-1250HB_CODEPAGE_HUWIN"HUWIN"cphuwin.c
Italian437HB_CODEPAGE_IT437"IT437"cpit437.c
Italian850HB_CODEPAGE_IT850"IT850"cpit850.c
ItalianISO-8859-1HB_CODEPAGE_ITISO"ITISO"cpitiso.c
ItalianISO-8859-1bHB_CODEPAGE_ITISB"ITISB"cpitisb.c
 (with BOX chars)   
LithuanianWindows-1257HB_CODEPAGE_LT"LT"cpltwin.c
Polish852HB_CODEPAGE_PL852"PL852"cppl852.c
PolishISO-8859-2HB_CODEPAGE_PLISO"PLISO"cppliso.c
PolishMazoviaHB_CODEPAGE_PLMAZ"PLMAZ"cpplmaz.c
PolishWindows-1250HB_CODEPAGE_PLWIN"PLWIN"cpplwin.c
Portuguese850HB_CODEPAGE_PT850"PT850"cppt850.c
PortugueseISO-8859-1HB_CODEPAGE_PTISO"PTISO"cpptiso.c
RussianWindows-1251HB_CODEPAGE_RU1251"RU1251"cpruwin.c
Russian866HB_CODEPAGE_RU866"RU866"cpru866.c
RussianKOI-8HB_CODEPAGE_RUKOI8"RUKOI8"cprukoi.c
SerbianWindows-1251HB_CODEPAGE_SRWIN"SRWIN"cpsrwin.c
Slovenian852HB_CODEPAGE_SL852"SL852"cpsl852.c
SlovenianISO-8859-2HB_CODEPAGE_SLISO"SLISO"cpsliso.c
SlovenianWindows-1250HB_CODEPAGE_SLWIN"SLWIN"cpslwin.c
Spanish850HB_CODEPAGE_ES"ES"cpesdos.c
Spanish (Modern)ISO-8859-1HB_CODEPAGE_ESMWIN"ESMWIN"cpesmwin.c
SpanishISO-8859-1HB_CODEPAGE_ESWIN"ESWIN"cpeswin.c
UkrainianWindows-1251HB_CODEPAGE_UA1251"UA1251"cpuawin.c
Ukrainian866HB_CODEPAGE_UA866"UA866"cpua866.c
UkrainianKOI-8UHB_CODEPAGE_UAKOI8"UAKOI8"cpuakoi.c

Info

See also:HB_AnsiToOem(), HB_LangSelect(), HB_OemToAnsi(), HB_Translate()
Category: Language specific , xHarbour extensions
Source:rtl\cdpapi.c, codepage\cp*.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates the influence of the selected code page
// on character comparison. It uses German umlauts and shows their
// sorting weight in the English and German alphabet.

   REQUEST HB_CODEPAGE_DEWIN

   PROCEDURE Main
      LOCAL aChr := { "A", "B", "O", "P", "U", "V", "Ä", "Ö", "Ü" }
      LOCAL cDE  := "", cEN := ""

      ? HB_SetCodePage()               // result: EN
      ? "Ä" > "B"                      // result: .T.

      ASort( aChr )
      ? "Sorted: "
      cEN := ""
      AEval( aChr, {|c| cEN += c } )
      ? HB_AnsiToOem( cEN )            // result: ABOPUVÄÖÜ

      HB_SetCodePage( "DEWIN" )

      ? HB_SetCodePage()               // result: DEWIN
      ? "Ä" > "B"                      // result: .F.

      ASort( aChr )
      ? "Sorted: "
      AEval( aChr, {|c| cDE += c } )
      ? HB_AnsiToOem( cDE )            // result: AÄBOÖPUÜV
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe