xHarbour Reference Documentation > Function Reference |
Queries or changes the current code page.
HB_SetCodePage( [<cCodePageID>] ) --> cOldCodePageID
The function returns a character string identifying the code page selected before the function is called.
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 name | Code page | REQUEST symbol | <cCodePageID> | Source file |
---|---|---|---|---|
Bulgarian | Windows-1251 | HB_CODEPAGE_BG1251 | "BG1251" | cpbgwin.c |
Bulgarian | MIK | HB_CODEPAGE_BGMIK | "BGMIK" | cpbgmik.c |
Croatien | 1250 | HB_CODEPAGE_HR1250 | "HR1250" | cphr1250.c |
Croatien | 437 | HB_CODEPAGE_HR437 | "HR437" | cphr437.c |
Croatien | 852 | HB_CODEPAGE_HR852 | "HR852" | cphr852.c |
English | 437 | none | "EN" | cp_tpl.c |
French | 850 | HB_CODEPAGE_FR | "FR" | cpfrdos.c |
German | 850 | HB_CODEPAGE_DE | "DE" | cpgedos.c |
German | ISO-8859-1 | HB_CODEPAGE_DEWIN | "DEWIN" | cpgewin.c |
Greek (Dos) | 737 | HB_CODEPAGE_EL | "EL" | cpeldos.c |
Greek WIN | ANSI (1253) | HB_CODEPAGE_ELWIN | "ELWIN" | cpelwin.c |
Hungarian | 852 | HB_CODEPAGE_HU852 | "HU852" | cphu852.c |
Hungarian | Windows-1250 | HB_CODEPAGE_HUWIN | "HUWIN" | cphuwin.c |
Italian | 437 | HB_CODEPAGE_IT437 | "IT437" | cpit437.c |
Italian | 850 | HB_CODEPAGE_IT850 | "IT850" | cpit850.c |
Italian | ISO-8859-1 | HB_CODEPAGE_ITISO | "ITISO" | cpitiso.c |
Italian | ISO-8859-1b | HB_CODEPAGE_ITISB | "ITISB" | cpitisb.c |
(with BOX chars) | ||||
Lithuanian | Windows-1257 | HB_CODEPAGE_LT | "LT" | cpltwin.c |
Polish | 852 | HB_CODEPAGE_PL852 | "PL852" | cppl852.c |
Polish | ISO-8859-2 | HB_CODEPAGE_PLISO | "PLISO" | cppliso.c |
Polish | Mazovia | HB_CODEPAGE_PLMAZ | "PLMAZ" | cpplmaz.c |
Polish | Windows-1250 | HB_CODEPAGE_PLWIN | "PLWIN" | cpplwin.c |
Portuguese | 850 | HB_CODEPAGE_PT850 | "PT850" | cppt850.c |
Portuguese | ISO-8859-1 | HB_CODEPAGE_PTISO | "PTISO" | cpptiso.c |
Russian | Windows-1251 | HB_CODEPAGE_RU1251 | "RU1251" | cpruwin.c |
Russian | 866 | HB_CODEPAGE_RU866 | "RU866" | cpru866.c |
Russian | KOI-8 | HB_CODEPAGE_RUKOI8 | "RUKOI8" | cprukoi.c |
Serbian | Windows-1251 | HB_CODEPAGE_SRWIN | "SRWIN" | cpsrwin.c |
Slovenian | 852 | HB_CODEPAGE_SL852 | "SL852" | cpsl852.c |
Slovenian | ISO-8859-2 | HB_CODEPAGE_SLISO | "SLISO" | cpsliso.c |
Slovenian | Windows-1250 | HB_CODEPAGE_SLWIN | "SLWIN" | cpslwin.c |
Spanish | 850 | HB_CODEPAGE_ES | "ES" | cpesdos.c |
Spanish (Modern) | ISO-8859-1 | HB_CODEPAGE_ESMWIN | "ESMWIN" | cpesmwin.c |
Spanish | ISO-8859-1 | HB_CODEPAGE_ESWIN | "ESWIN" | cpeswin.c |
Ukrainian | Windows-1251 | HB_CODEPAGE_UA1251 | "UA1251" | cpuawin.c |
Ukrainian | 866 | HB_CODEPAGE_UA866 | "UA866" | cpua866.c |
Ukrainian | KOI-8U | HB_CODEPAGE_UAKOI8 | "UAKOI8" | cpuakoi.c |
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 |
// 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
http://www.xHarbour.com