Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
locale.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_LOCALE_H
27#define _ULTIBO_LOCALE_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/globaltypes.h"
34#include "ultibo/globalconst.h"
35#include "ultibo/sysutils.h"
36
38
40#define CP_ACP 0
41#define CP_OEMCP 1
42#define CP_MACCP 2
43#define CP_THREAD_ACP 3
44#define CP_SYMBOL 42
45#define CP_UTF16 1200
46#define CP_UNICODE 1200
47#define CP_UTF16_BE 1201
48#define CP_UTF7 65000
49#define CP_UTF8 65001
50//#define CP_ASCII 20127 {US-ASCII}
51//#define CP_NONE 0xFFFF {FPC RawByteString}
52
54#define CP_OEM_437 437
55#define CP_OEM_720 720
56#define CP_OEM_737 737
57#define CP_OEM_775 775
58#define CP_OEM_850 850
59#define CP_OEM_852 852
60#define CP_OEM_857 857
61#define CP_OEM_862 862
62#define CP_OEM_866 866
63#define CP_OEM_874 874
64#define CP_OEM_1258 1258
65
66#define CP_ANSI_1250 1250
67#define CP_ANSI_1251 1251
68#define CP_ANSI_1252 1252
69#define CP_ANSI_1253 1253
70#define CP_ANSI_1254 1254
71#define CP_ANSI_1255 1255
72#define CP_ANSI_1256 1256
73#define CP_ANSI_1257 1257
74#define CP_ANSI_1258 1258
75#define CP_ANSI_874 874
76
78#define LOCALE_SYSTEM_DEFAULT 0x800
79#define LOCALE_USER_DEFAULT 0x400
80
82#define MAX_LEADBYTES 12
83#define MAX_DEFAULTCHAR 2
84
86#define MB_PRECOMPOSED 0x00000001
87#define MB_COMPOSITE 0x00000002
88#define MB_USEGLYPHCHARS 0x00000004
89#define MB_ERR_INVALID_CHARS 0x00000008
90
91#define WC_COMPOSITECHECK 0x00000200
92#define WC_DISCARDNS 0x00000010
93#define WC_SEPCHARS 0x00000020
94#define WC_DEFAULTCHAR 0x00000040
95
96#define WC_NO_BEST_FIT_CHARS 0x00000400
97
99#define CT_CTYPE1 0x00000001
100#define CT_CTYPE2 0x00000002
101#define CT_CTYPE3 0x00000004
102
104#define C1_UPPER 0x0001
105#define C1_LOWER 0x0002
106#define C1_DIGIT 0x0004
107#define C1_SPACE 0x0008
108#define C1_PUNCT 0x0010
109#define C1_CNTRL 0x0020
110#define C1_BLANK 0x0040
111#define C1_XDIGIT 0x0080
112#define C1_ALPHA 0x0100
113#define C1_DEFINED 0x0200
114
116#define C2_LEFTTORIGHT 0x0001
117#define C2_RIGHTTOLEFT 0x0002
118
119#define C2_EUROPENUMBER 0x0003
120#define C2_EUROPESEPARATOR 0x0004
121#define C2_EUROPETERMINATOR 0x0005
122#define C2_ARABICNUMBER 0x0006
123#define C2_COMMONSEPARATOR 0x0007
124
125#define C2_BLOCKSEPARATOR 0x0008
126#define C2_SEGMENTSEPARATOR 0x0009
127#define C2_WHITESPACE 0x000A
128#define C2_OTHERNEUTRAL 0x000B
129
130#define C2_NOTAPPLICABLE 0x0000
131
133#define C3_NONSPACING 0x0001
134#define C3_DIACRITIC 0x0002
135#define C3_VOWELMARK 0x0004
136#define C3_SYMBOL 0x0008
137
138#define C3_KATAKANA 0x0010
139#define C3_HIRAGANA 0x0020
140#define C3_HALFWIDTH 0x0040
141#define C3_FULLWIDTH 0x0080
142#define C3_IDEOGRAPH 0x0100
143#define C3_KASHIDA 0x0200
144#define C3_LEXICAL 0x0400
145
146#define C3_ALPHA 0x8000
147
148#define C3_NOTAPPLICABLE 0x0000
149
151#define NORM_IGNORECASE 0x00000001
152#define NORM_IGNORENONSPACE 0x00000002
153#define NORM_IGNORESYMBOLS 0x00000004
154
155#define NORM_IGNOREKANATYPE 0x00010000
156#define NORM_IGNOREWIDTH 0x00020000
157
159#define MAP_FOLDCZONE 0x00000010
160#define MAP_PRECOMPOSED 0x00000020
161#define MAP_COMPOSITE 0x00000040
162#define MAP_FOLDDIGITS 0x00000080
163
164#define MAP_EXPAND_LIGATURES 0x00002000
165
167#define LCMAP_LOWERCASE 0x00000100
168#define LCMAP_UPPERCASE 0x00000200
169#define LCMAP_SORTKEY 0x00000400
170#define LCMAP_BYTEREV 0x00000800
171
172#define LCMAP_HIRAGANA 0x00100000
173#define LCMAP_KATAKANA 0x00200000
174#define LCMAP_HALFWIDTH 0x00400000
175#define LCMAP_FULLWIDTH 0x00800000
176
177#define LCMAP_LINGUISTIC_CASING 0x01000000
178
179#define LCMAP_SIMPLIFIED_CHINESE 0x02000000
180#define LCMAP_TRADITIONAL_CHINESE 0x04000000
181
183#define LGRPID_INSTALLED 0x00000001
184#define LGRPID_SUPPORTED 0x00000002
185
187#define LCID_INSTALLED 0x00000001
188#define LCID_SUPPORTED 0x00000002
189#define LCID_ALTERNATE_SORTS 0x00000004
190
192#define CP_INSTALLED 0x00000001
193#define CP_SUPPORTED 0x00000002
194
199//
209//
210//
212//
222//
223#define SORT_STRINGSORT 0x00001000
224
226#define CSTR_LESS_THAN 1
227#define CSTR_EQUAL 2
228#define CSTR_GREATER_THAN 3
229
231#define CTRY_DEFAULT 0
232
233#define CTRY_ALBANIA 355
234#define CTRY_ALGERIA 213
235#define CTRY_ARGENTINA 54
236#define CTRY_ARMENIA 374
237#define CTRY_AUSTRALIA 61
238#define CTRY_AUSTRIA 43
239#define CTRY_AZERBAIJAN 994
240#define CTRY_BAHRAIN 973
241#define CTRY_BELARUS 375
242#define CTRY_BELGIUM 32
243#define CTRY_BELIZE 501
244#define CTRY_BOLIVIA 591
245#define CTRY_BRAZIL 55
246#define CTRY_BRUNEI_DARUSSALAM 673
247#define CTRY_BULGARIA 359
248#define CTRY_CANADA 2
249#define CTRY_CARIBBEAN 1
250#define CTRY_CHILE 56
251#define CTRY_COLOMBIA 57
252#define CTRY_COSTA_RICA 506
253#define CTRY_CROATIA 385
254#define CTRY_CZECH 420
255#define CTRY_DENMARK 45
256#define CTRY_DOMINICAN_REPUBLIC 1
257#define CTRY_ECUADOR 593
258#define CTRY_EGYPT 20
259#define CTRY_EL_SALVADOR 503
260#define CTRY_ESTONIA 372
261#define CTRY_FAEROE_ISLANDS 298
262#define CTRY_FINLAND 358
263#define CTRY_FRANCE 33
264#define CTRY_GEORGIA 995
265#define CTRY_GERMANY 49
266#define CTRY_GREECE 30
267#define CTRY_GUATEMALA 502
268#define CTRY_HONDURAS 504
269#define CTRY_HONG_KONG 852
270#define CTRY_HUNGARY 36
271#define CTRY_ICELAND 354
272#define CTRY_INDIA 91
273#define CTRY_INDONESIA 62
274#define CTRY_IRAN 981
275#define CTRY_IRAQ 964
276#define CTRY_IRELAND 353
277#define CTRY_ISRAEL 972
278#define CTRY_ITALY 39
279#define CTRY_JAMAICA 1
280#define CTRY_JAPAN 81
281#define CTRY_JORDAN 962
282#define CTRY_KAZAKSTAN 7
283#define CTRY_KENYA 254
284#define CTRY_KUWAIT 965
285#define CTRY_KYRGYZSTAN 996
286#define CTRY_LATVIA 371
287#define CTRY_LEBANON 961
288#define CTRY_LIBYA 218
289#define CTRY_LIECHTENSTEIN 41
290#define CTRY_LITHUANIA 370
291#define CTRY_LUXEMBOURG 352
292#define CTRY_MACAU 853
293#define CTRY_MACEDONIA 389
294#define CTRY_MALAYSIA 60
295#define CTRY_MALDIVES 960
296#define CTRY_MEXICO 52
297#define CTRY_MONACO 33
298#define CTRY_MONGOLIA 976
299#define CTRY_MOROCCO 212
300#define CTRY_NETHERLANDS 31
301#define CTRY_NEW_ZEALAND 64
302#define CTRY_NICARAGUA 505
303#define CTRY_NORWAY 47
304#define CTRY_OMAN 968
305#define CTRY_PAKISTAN 92
306#define CTRY_PANAMA 507
307#define CTRY_PARAGUAY 595
308#define CTRY_PERU 51
309#define CTRY_PHILIPPINES 63
310#define CTRY_POLAND 48
311#define CTRY_PORTUGAL 351
312#define CTRY_PRCHINA 86
313#define CTRY_PUERTO_RICO 1
314#define CTRY_QATAR 974
315#define CTRY_ROMANIA 40
316#define CTRY_RUSSIA 7
317#define CTRY_SAUDI_ARABIA 966
318#define CTRY_SERBIA 381
319#define CTRY_SINGAPORE 65
320#define CTRY_SLOVAK 421
321#define CTRY_SLOVENIA 386
322#define CTRY_SOUTH_AFRICA 27
323#define CTRY_SOUTH_KOREA 82
324#define CTRY_SPAIN 34
325#define CTRY_SWEDEN 46
326#define CTRY_SWITZERLAND 41
327#define CTRY_SYRIA 963
328#define CTRY_TAIWAN 886
329#define CTRY_TATARSTAN 7
330#define CTRY_THAILAND 66
331#define CTRY_TRINIDAD_Y_TOBAGO 1
332#define CTRY_TUNISIA 216
333#define CTRY_TURKEY 90
334#define CTRY_UAE 971
335#define CTRY_UKRAINE 380
336#define CTRY_UNITED_KINGDOM 44
337#define CTRY_UNITED_STATES 1
338#define CTRY_URUGUAY 598
339#define CTRY_UZBEKISTAN 7
340#define CTRY_VENEZUELA 58
341#define CTRY_VIET_NAM 84
342#define CTRY_YEMEN 967
343#define CTRY_ZIMBABWE 263
344
347
350
353
356
359
362
365
367#define LANG_NEUTRAL 0x00
369#define LANG_ENGLISH 0x09
371
373#define SUBLANG_NEUTRAL 0x00
374#define SUBLANG_DEFAULT 0x01
375#define SUBLANG_SYS_DEFAULT 0x02
377#define SUBLANG_ENGLISH_US 0x01
379
381
383typedef uint32_t LCID;
384typedef uint16_t LANGID;
385
387typedef uint32_t LGRPID;
389typedef uint32_t LCTYPE;
391typedef uint32_t CALTYPE;
393typedef uint32_t CALID;
394
396typedef struct _CPINFO CPINFO;
398{
399 unsigned int maxcharsize;
402};
403
405
406typedef struct _CPINFOEXA CPINFOEXA;
416
418
419typedef struct _CPINFOEXW CPINFOEXW;
429
431
433
435typedef struct _CODE_TABLE CODE_TABLE;
437{
438 unsigned int maxcharsize;
441 uint16_t values[0xFF];
442};
443
447{
448 uint16_t transid;
449 uint16_t values[0xFF];
450};
451
455{
456 uint16_t lowerid;
457 uint16_t values[0xFF];
458};
459
463{
464 uint16_t upperid;
465 uint16_t values[0xFF];
466};
467
471{
472 uint16_t values[0xFFFF];
473};
474
476typedef struct _LEAD_BYTES LEAD_BYTES;
478{
479 CODE_TABLE* tables[0xFF]; //To Do //Test
480};
481
485
487typedef struct _CODE_PAGE CODE_PAGE;
501
503
507BOOL STDCALL IsValidCodePage(unsigned int codepage);
508
512unsigned int STDCALL GetACP(void);
513
517unsigned int STDCALL GetOEMCP(void);
518
522BOOL STDCALL SetACP(unsigned int codepage);
523
527BOOL STDCALL SetOEMCP(unsigned int codepage);
528
532unsigned int STDCALL GetConsoleCP(void);
533
537BOOL STDCALL SetConsoleCP(unsigned int wcodepageid);
538
542unsigned int STDCALL GetConsoleOutputCP(void);
543
547BOOL STDCALL SetConsoleOutputCP(unsigned int wcodepageid);
548
552BOOL STDCALL GetCPInfo(unsigned int codepage, CPINFO *lpcpinfo);
553
557BOOL STDCALL GetCPInfoEx(unsigned int codepage, uint32_t dwflags, CPINFOEXA *lpcpinfoex);
558
562BOOL STDCALL GetCPInfoExA(unsigned int codepage, uint32_t dwflags, CPINFOEXA *lpcpinfoex);
563
567BOOL STDCALL GetCPInfoExW(unsigned int codepage, uint32_t dwflags, CPINFOEXW *lpcpinfoex);
568
572BOOL STDCALL IsValidLocale(LCID locale, uint32_t dwflags);
573
579
585
591
597
603
605
609uint16_t STDCALL map_page(unsigned int codepage);
610
614CODE_PAGE * STDCALL get_page(uint16_t pageid);
615
620
625
630
634BOOL STDCALL load_page(uint16_t pageid, CODE_TABLE *table, LOWER_TABLE *lower, UPPER_TABLE *upper);
635
639BOOL STDCALL unload_page(uint16_t pageid, CODE_PAGE *page);
640
641BOOL STDCALL default_trans(uint16_t pageid, uint16_t transid);
642BOOL STDCALL install_trans(uint16_t pageid, TRANS_TABLE *table);
643
644#ifdef __cplusplus
645}
646#endif
647
648#endif // _ULTIBO_LOCALE_H
size_t HANDLE
Definition globaltypes.h:51
#define STDCALL
Definition globaltypes.h:45
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
wchar_t WCHAR
Standard WideChar type (2 bytes) (Redeclared here for flexibility).
Definition globaltypes.h:58
CPINFOEXA CPINFOEX
Definition locale.h:432
struct _CPINFO CPINFO
Definition locale.h:396
BOOL STDCALL SetConsoleCP(unsigned int wcodepageid)
Set the input code page used by the console for the system.
LCID STDCALL GetSystemDefaultLCID(void)
Return the locale identifier for the system locale.
struct _TRANS_TABLE TRANS_TABLE
Definition locale.h:445
unsigned int STDCALL GetConsoleOutputCP(void)
Retrieve the output code page used by the console for the system.
BOOL STDCALL IsValidLocale(LCID locale, uint32_t dwflags)
Determine if the specified locale is installed or supported on the system.
BOOL STDCALL install_trans(uint16_t pageid, TRANS_TABLE *table)
struct _UNICODE_TABLE UNICODE_TABLE
Definition locale.h:469
struct _CPINFOEXW CPINFOEXW
Definition locale.h:419
BOOL STDCALL SetOEMCP(unsigned int codepage)
Set the current original equipment manufacturer (OEM) code page identifier for the system.
struct _CODE_TABLE CODE_TABLE
Definition locale.h:435
uint16_t STDCALL map_page(unsigned int codepage)
Map a default code page to the actual current page.
BOOL STDCALL IsValidCodePage(unsigned int codepage)
Determine if a specified code page is valid.
unsigned int STDCALL GetConsoleCP(void)
Retrieve the input code page used by the console for the system.
LANGID STDCALL GetSystemDefaultLangID(void)
Get the System Default Language Identifier (Combined Primary and Sub language Identifiers).
uint32_t CALID
Definition locale.h:393
struct _CODE_PAGE CODE_PAGE
Definition locale.h:487
uint32_t LCID
To Do.
Definition locale.h:383
BOOL STDCALL default_trans(uint16_t pageid, uint16_t transid)
BOOL STDCALL SetConsoleOutputCP(unsigned int wcodepageid)
Set the output code page used by the console for the system.
#define MAX_DEFAULTCHAR
single or double byte
Definition locale.h:83
CPINFOEXW _cpinfoexW
Definition locale.h:430
uint32_t LGRPID
Definition locale.h:387
struct _UPPER_TABLE UPPER_TABLE
Definition locale.h:461
unsigned int STDCALL GetACP(void)
Retrieve the current ANSI code page identifier for the system.
BOOL STDCALL SetACP(unsigned int codepage)
Set the current ANSI code page identifier for the system.
struct _CPINFOEXA CPINFOEXA
Definition locale.h:406
LCID STDCALL GetUserDefaultLCID(void)
Return the locale identifier for the user default locale.
unsigned int STDCALL GetOEMCP(void)
Return the current original equipment manufacturer (OEM) code page identifier for the system.
BOOL STDCALL unlink_page(CODE_PAGE *page)
Unlink Page from Prev,Next Siblings and Adjust First/Last.
BOOL STDCALL link_page(CODE_PAGE *page)
Link Page to Prev,Next Siblings and Adjust First/Last.
uint16_t LANGID
Definition locale.h:384
CODE_PAGE *STDCALL get_page(uint16_t pageid)
Find the requested page in the linked list.
uint32_t LCTYPE
Definition locale.h:389
BOOL STDCALL GetCPInfoExW(unsigned int codepage, uint32_t dwflags, CPINFOEXW *lpcpinfoex)
Retrieve information about any valid installed or available code page.
CPINFOEXA _cpinfoexA
Definition locale.h:417
uint32_t CALTYPE
Definition locale.h:391
BOOL STDCALL SetSystemDefaultLCID(LCID locale)
Set the locale identifier for the system locale.
BOOL STDCALL GetCPInfoEx(unsigned int codepage, uint32_t dwflags, CPINFOEXA *lpcpinfoex)
Retrieve information about any valid installed or available code page.
struct _LEAD_BYTES LEAD_BYTES
Definition locale.h:476
BOOL STDCALL GetCPInfoExA(unsigned int codepage, uint32_t dwflags, CPINFOEXA *lpcpinfoex)
Retrieve information about any valid installed or available code page.
BOOL STDCALL load_page(uint16_t pageid, CODE_TABLE *table, LOWER_TABLE *lower, UPPER_TABLE *upper)
Load a code table and allocate memory to create a code page.
BOOL STDCALL unload_page(uint16_t pageid, CODE_PAGE *page)
Unload a code page and release allocated memory.
struct _LOWER_TABLE LOWER_TABLE
Definition locale.h:453
BOOL STDCALL GetCPInfo(unsigned int codepage, CPINFO *lpcpinfo)
Retrieve information about any valid installed or available code page.
BOOL STDCALL check_page(CODE_PAGE *page)
Check that the Page supplied is part of the Linked list.
CPINFO _cpinfo
Definition locale.h:404
#define MAX_LEADBYTES
5 ranges, 2 bytes each, 0 terminated
Definition locale.h:82
LANGID STDCALL GetUserDefaultLangID(void)
Get the System Default Language Identifier (Combined Primary and Sub language Identifiers).
Definition locale.h:489
TRANS_TABLE * transtable
The OEM <-> ANSI Values.
Definition locale.h:494
HANDLE handle
Handle of Code Page Module.
Definition locale.h:491
UPPER_TABLE * uppertable
The Lower to Upper Values.
Definition locale.h:496
CODE_PAGE * nextpage
Next Code Page.
Definition locale.h:499
CODE_TABLE * codetable
The OEM/ANSI Values.
Definition locale.h:492
CODE_PAGE * prevpage
Prev Code Page.
Definition locale.h:498
LEAD_BYTES * leadbytes
The Lead Byte Tables.
Definition locale.h:493
UNICODE_TABLE * unicodetable
The UNICODE Values.
Definition locale.h:497
uint16_t pageid
Code Page ID (eg 437 or 1252).
Definition locale.h:490
LOWER_TABLE * lowertable
The Upper to Lower Values.
Definition locale.h:495
Definition locale.h:437
uint8_t leadbyte[MAX_LEADBYTES]
Lead Byte Ranges.
Definition locale.h:440
uint8_t defaultchar[MAX_DEFAULTCHAR]
Default Character.
Definition locale.h:439
unsigned int maxcharsize
Max Length (Bytes) of a Char.
Definition locale.h:438
uint16_t values[0xFF]
Definition locale.h:441
Definition locale.h:408
uint8_t leadbyte[MAX_LEADBYTES]
lead byte ranges
Definition locale.h:411
uint8_t defaultchar[MAX_DEFAULTCHAR]
default character (MB)
Definition locale.h:410
WCHAR unicodedefaultchar
default character (Unicode)
Definition locale.h:412
unsigned int maxcharsize
max length (in bytes) of a AnsiChar
Definition locale.h:409
char codepagename[MAX_PATH]
code page name (Ansi)
Definition locale.h:414
unsigned int codepage
code page id
Definition locale.h:413
Definition locale.h:421
WCHAR codepagename[MAX_PATH]
code page name (Unicode)
Definition locale.h:427
uint8_t leadbyte[MAX_LEADBYTES]
lead byte ranges
Definition locale.h:424
uint8_t defaultchar[MAX_DEFAULTCHAR]
default character (MB)
Definition locale.h:423
WCHAR unicodedefaultchar
default character (Unicode)
Definition locale.h:425
unsigned int maxcharsize
max length (in bytes) of a AnsiChar
Definition locale.h:422
unsigned int codepage
code page id
Definition locale.h:426
Definition locale.h:398
uint8_t leadbyte[MAX_LEADBYTES]
lead byte ranges
Definition locale.h:401
uint8_t defaultchar[MAX_DEFAULTCHAR]
default character
Definition locale.h:400
unsigned int maxcharsize
max length (in bytes) of a AnsiChar
Definition locale.h:399
Definition locale.h:478
CODE_TABLE * tables[0xFF]
Definition locale.h:479
Definition locale.h:455
uint16_t lowerid
Lowercase Code Page.
Definition locale.h:456
uint16_t values[0xFF]
Word to allow for DBCS.
Definition locale.h:457
Definition locale.h:447
uint16_t transid
Translate Code Page.
Definition locale.h:448
uint16_t values[0xFF]
Word to allow for DBCS.
Definition locale.h:449
Definition locale.h:471
uint16_t values[0xFFFF]
Word to allow for DBCS.
Definition locale.h:472
Definition locale.h:463
uint16_t upperid
Uppercase Code Page.
Definition locale.h:464
uint16_t values[0xFF]
Word to allow for DBCS.
Definition locale.h:465
#define MAX_PATH
Maximum length for a file path.
Definition sysutils.h:37