Difference between revisions of "Unit Locale"

From Ultibo.org
Jump to: navigation, search
Line 926: Line 926:
 
----
 
----
  
''To be documented''
+
 
 +
'''Locale Id'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>LCID = DWORD;</code>
 +
| style="width: 40%;"|
 +
|-
 +
| <code>PLCID = ^LCID;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Language Id'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>LANGID = Word;</code>
 +
| style="width: 40%;"|
 +
|-
 +
| <code>PLANGID = ^LANGID;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Language group Id'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>LGRPID = DWORD;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Locale type'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>LCTYPE = DWORD;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Calendar type'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>CALTYPE = DWORD;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 +
'''Calendar Id'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>CALID = DWORD;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''CP information'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>CPINFO = _cpinfo;</code>
 +
 
 +
<code>TCpInfo = CPINFO;</code>
 +
 
 +
<code>PCpInfo = LPCPINFO;</code>
 +
 
 +
<code>LPCPINFO = ^CPINFO;</code>
 +
 
 +
<code>_cpinfo = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>MaxCharSize: UINT;</code>
 +
| max length (in bytes) of a AnsiChar
 +
|-
 +
| <code>DefaultChar: array [0..MAX_DEFAULTCHAR - 1] of BYTE;</code>
 +
| default character
 +
|-
 +
| <code>LeadByte: array [0..MAX_LEADBYTES - 1] of BYTE;</code>
 +
| lead byte ranges
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''CP info extended'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>CPINFOEX = _cpinfoex;</code>
 +
 
 +
<code>TCpInfoEx = CPINFOEX;</code>
 +
 
 +
<code>PCpInfoEx = LPCPINFOEX;</code>
 +
 
 +
<code>LPCPINFOEX = ^CPINFOEX;</code>
 +
 
 +
<code>_cpinfoex = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>MaxCharSize: UINT;</code>
 +
| max length (in bytes) of a AnsiChar
 +
|-
 +
| <code>DefaultChar: array [0..MAX_DEFAULTCHAR - 1] of BYTE;</code>
 +
| default character (MB)
 +
|-
 +
| <code>LeadByte: array [0..MAX_LEADBYTES - 1] of BYTE;</code>
 +
| lead byte ranges
 +
|-
 +
| <code>UnicodeDefaultChar: WCHAR;</code>
 +
| default character (Unicode)
 +
|-
 +
| <code>CodePage: UINT;</code>
 +
| code page id
 +
|-
 +
| <code>CodePageName: array [0..MAX_PATH - 1] of AnsiChar;</code>
 +
| code page name (Ansi)
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''Code table'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PCodeTable = ^TCodeTable;</code>
 +
 
 +
<code>TCodeTable = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Code Table - The OEM/ANSI to UNICODE Values of a Code Page
 +
|-
 +
| <code>MaxCharSize:UINT;</code>
 +
| Max Length (Bytes) of a Char
 +
|-
 +
| <code>DefaultChar:array[0..MAX_DEFAULTCHAR - 1] of Byte;</code>
 +
| Default Character
 +
|-
 +
| <code>LeadByte:array[0..MAX_LEADBYTES - 1] of Byte;</code>
 +
| Lead Byte Ranges
 +
|-
 +
| <code>Values:array[$00..$FF] of Word;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div> 
 +
 +
'''Translation table'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTransTable = ^TTransTable;</code>
 +
 
 +
<code>TTransTable = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Trans Table - The OEM/ANSI to ANSI/OEM Values of a Code Page
 +
|-
 +
| <code>TransID:Word;</code>
 +
| Translate Code Page
 +
|-
 +
| <code>Values:array[$00..$FF] of Word;</code>
 +
| Word to allow for DBCS
 +
|-
 +
|}
 +
</div></div> 
 +
 +
'''Lowercase table'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PLowerTable = ^TLowerTable;</code>
 +
 
 +
<code>TLowerTable = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Lower Table - Upper to Lower case values of a Code Page
 +
|-
 +
| <code>LowerID:Word;</code>
 +
| Lowercase Code Page
 +
|-
 +
| <code>Values:array[$00..$FF] of Word;</code>
 +
| Word to allow for DBCS
 +
|-
 +
|}
 +
</div></div> 
 +
 +
'''Uppercase table'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PUpperTable = ^TUpperTable;</code>
 +
 
 +
<code>TUpperTable = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Upper Table - Lower to Upper case values of a Code Page
 +
|-
 +
| <code>UpperID:Word;</code>
 +
| Uppercase Code Page
 +
|-
 +
| <code>Values:array[$00..$FF] of Word;</code>
 +
| Word to allow for DBCS
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Unicode table'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PUnicodeTable = ^TUnicodeTable;</code>
 +
 
 +
<code>TUnicodeTable = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Unicode Table - The UNICODE to OEM/ANSI Values of a Code Page
 +
|-
 +
| <code>Values:array[$0000..$FFFF] of Word;</code>
 +
| Word to allow for DBCS
 +
|-
 +
|}
 +
</div></div> 
 +
 +
'''Lead bytes'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PLeadBytes = ^TLeadBytes;</code>
 +
 
 +
<code>TLeadBytes = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Lead Bytes - The extended Page Tables for DBCS Pages
 +
|-
 +
| <code>Tables:array[$00..$FF] of PCodeTable;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Code page'''
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PCodePage = ^TCodePage;</code>
 +
 
 +
<code>TCodePage = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Each Code Table provides the OEM to UNICODE Values. To convert back use the main Unicode Table in the Code Page which was populated when the Code Page was loaded.
 +
|-
 +
|colspan="2"|Note: Code Page - The actual information for an OEM/ANSI Code Page
 +
|-
 +
| <code>PageID:Word;</code>
 +
| Code Page ID (eg 437 or 1252)
 +
|-
 +
| <code>Handle:THandle;</code>
 +
| Handle of Code Page Module
 +
|-
 +
| <code>CodeTable:PCodeTable;</code>
 +
| The OEM/ANSI Values
 +
|-
 +
| <code>LeadBytes:PLeadBytes;</code>
 +
| The Lead Byte Tables
 +
|-
 +
| <code>TransTable:PTransTable;</code>
 +
| The OEM <-> ANSI Values
 +
|-
 +
| <code>LowerTable:PLowerTable;</code>
 +
| The Upper to Lower Values
 +
|-
 +
| <code>UpperTable:PUpperTable;</code>
 +
| The Lower to Upper Values
 +
|-
 +
| <code>UnicodeTable:PUnicodeTable;</code>
 +
| The UNICODE Values
 +
|-
 +
| <code>PrevPage:PCodePage;</code>
 +
| Prev Code Page
 +
|-
 +
| <code>NextPage:PCodePage;</code>
 +
| Next Code Page
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===

Revision as of 04:02, 27 January 2017

Return to Unit Reference


Description


Ultibo Locale interface unit

This unit implements the locale support for Ultibo and provides the code page support for the WideStringManager/UnicodeStringManager interface for the RTL.

This unit provides compatible implementations of the following functions:

  • ConvertDefaultLocale
  • EnumCodePagesProc
  • EnumLocalesProc
  • EnumTimeFormats
  • GetCPInfo
  • GetNumberFormat
  • GetSystemDefaultLangID
  • GetUserDefaultLangID
  • IsValidLocale
  • GetConsoleOutputCP
  • EnumCalendarInfo
  • EnumDateFormats
  • EnumSystemCodePages
  • EnumTimeFormatsProc
  • GetCurrencyFormat
  • GetLocaleInfo
  • GetSystemDefaultLCID
  • GetUserDefaultLCID
  • SetLocaleInfo
  • SetConsoleCP
  • EnumCalendarInfoProc
  • EnumDateFormatsProc
  • EnumSystemLocales
  • GetACP
  • GetDateFormat
  • GetOEMCP
  • GetTimeFormat
  • IsValidCodePage
  • GetConsoleCP
  • SetConsoleOutputCP


The following functions are implemented by the Threads unit:

  • GetThreadLocale (ThreadGetLocale) (GetThreadLocale is exposed in the Ultibo unit)
  • SetThreadLocale (ThreadSetLocale) (SetThreadLocale is exposed in the Ultibo unit)

Most of the above are currently not implemented.


OEM Code Page defaults to 437 (OEM United States)

ANSI Code Page defaults to 1252 (ANSI Latin 1; Western European (Windows))


See also: https://msdn.microsoft.com/en-us/library/windows/desktop/dd319081%28v=vs.85%29.aspx

Constants



[Expand]
Default code page constants CP_*


[Expand]
Code page identifier constants CP_OEM_*, CP_ANSI_*


[Expand]
Default locale constants LOCALE_*


[Expand]
String length maximum constants MAX_*


[Expand]
MBCS and Unicode translation flag constants MB_*, WC_*


[Expand]
Character type flag constants CT_*


[Expand]
CType 1 flag bit constants C1_*


[Expand]
CType 2 flag bit constants C2_*


[Expand]
CType 3 flag bit constants C3_*


[Expand]
String flag constants NORM_*


[Expand]
Locale independent mapping flag constants MAP_*


[Expand]
Locale dependent mapping flag constants LCMAP_*


[Expand]
Language group enumeration flag constants LGRPID_*


[Expand]
Locale enumeration flag constants LCID_*


[Expand]
Code page enumeration flag constants CP_*


[Expand]
Sorting flag constants SORT_*


[Expand]
Compare string return value constants CSTR_*


[Expand]
Country/Region code constants CTRY_*


Type definitions



Locale Id

LCID = DWORD;
PLCID = ^LCID;

Language Id

LANGID = Word;
PLANGID = ^LANGID;

Language group Id

LGRPID = DWORD;

Locale type

LCTYPE = DWORD;

Calendar type

CALTYPE = DWORD;

Calendar Id

CALID = DWORD;

CP information

[Expand]

CPINFO = _cpinfo;

TCpInfo = CPINFO;

PCpInfo = LPCPINFO;

LPCPINFO = ^CPINFO;

_cpinfo = record

CP info extended

[Expand]

CPINFOEX = _cpinfoex;

TCpInfoEx = CPINFOEX;

PCpInfoEx = LPCPINFOEX;

LPCPINFOEX = ^CPINFOEX;

_cpinfoex = record

Code table

[Expand]

PCodeTable = ^TCodeTable;

TCodeTable = record

Translation table

[Expand]

PTransTable = ^TTransTable;

TTransTable = record

Lowercase table

[Expand]

PLowerTable = ^TLowerTable;

TLowerTable = record

Uppercase table

[Expand]

PUpperTable = ^TUpperTable;

TUpperTable = record

Unicode table

[Expand]

PUnicodeTable = ^TUnicodeTable;

TUnicodeTable = record

Lead bytes

[Expand]

PLeadBytes = ^TLeadBytes;

TLeadBytes = record

Code page

[Expand]

PCodePage = ^TCodePage;

TCodePage = record


Public variables



Locale specific variables

OemPage:PCodePage;
AnsiPage:PCodePage;
DefaultPage:PCodePage;
CodePageLock:TPlatformLock;


Function declarations



Initialization functions

[Expand]
procedure LocaleInit;
Description: To be documented


Locale functions

[Expand]
function IsValidCodePage(CodePage:UINT):BOOL;
Description: To be documented


[Expand]
function GetACP:UINT;
Description: To be documented


[Expand]
function GetOEMCP:UINT;
Description: To be documented


[Expand]
function SetACP(CodePage:UINT):BOOL;
Description: To be documented


[Expand]
function SetOEMCP(CodePage:UINT):BOOL;
Description: To be documented


[Expand]
function GetConsoleCP:UINT;
Description: To be documented


[Expand]
function SetConsoleCP(wCodePageID:UINT):BOOL;
Description: To be documented


[Expand]
function GetConsoleOutputCP:UINT;
Description: To be documented


[Expand]
function SetConsoleOutputCP(wCodePageID:UINT):BOOL;
Description: To be documented


[Expand]
function GetCPInfo(CodePage:UINT; var lpCPInfo:TCPInfo):BOOL;
Description: To be documented


[Expand]
function GetCPInfoEx(CodePage:UINT; dwFlags:DWORD; var lpCPInfoEx:CPINFOEXA):BOOL;
Description: To be documented


[Expand]
function GetCPInfoExA(CodePage:UINT; dwFlags:DWORD; var lpCPInfoEx:CPINFOEXA):BOOL;
Description: To be documented


[Expand]
function GetCPInfoExW(CodePage:UINT; dwFlags:DWORD; var lpCPInfoEx:CPINFOEXW):BOOL;
Description: To be documented


[Expand]
function IsValidLocale(Locale:LCID; dwFlags:DWORD):BOOL;
Description: To be documented


[Expand]
function GetSystemDefaultLCID:LCID;
Description: To be documented


[Expand]
function GetUserDefaultLCID:LCID;
Description: To be documented


[Expand]
function SetSystemDefaultLCID(Locale:LCID):BOOL;
Description: To be documented


RTL unicode string manager functions

[Expand]
function SysGetStandardCodePage(const stdcp:TStandardCodePageEnum):TSystemCodePage;
Description: To be documented


Locale helper functions

[Expand]
function MapPage(CodePage:UINT):Word;
Description: Map a default code page to the actual current page


[Expand]
function GetPage(PageID:Word):PCodePage;
Description: Find the requested page in the linked list


[Expand]
function CheckPage(Page:PCodePage):Boolean;
Description: Check that the Page supplied is part of the Linked list


[Expand]
function LinkPage(Page:PCodePage):Boolean;
Description: Link Page to Prev,Next Siblings and Adjust First/Last


[Expand]
function UnlinkPage(Page:PCodePage):Boolean;
Description: Unlink Page from Prev,Next Siblings and Adjust First/Last


[Expand]
function LoadPage(PageID:Word; Table:PCodeTable; Lower:PLowerTable; Upper:PUpperTable):Boolean;
Description: Load a code table and allocate memory to create a code page


[Expand]
function UnloadPage(PageID:Word; Page:PCodePage):Boolean;
Description: Unload a code page and release allocated memory


[Expand]
function DefaultTrans(PageID,TransID:Word):Boolean;
Description: To be documented


[Expand]
function InstallTrans(PageID:Word; Table:PTransTable):Boolean;
Description: To be documented


Return to Unit Reference