4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
6 * Copyright 2000 Julio César Gázquez
7 * Copyright 2002 Alexandre Julliard for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/port.h"
36 # include <CoreFoundation/CFBundle.h>
37 # include <CoreFoundation/CFLocale.h>
38 # include <CoreFoundation/CFString.h>
42 #define WIN32_NO_STATUS
45 #include "winuser.h" /* for RT_STRINGW */
47 #include "wine/unicode.h"
51 #include "kernel_private.h"
52 #include "wine/debug.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(nls
);
56 #define LOCALE_LOCALEINFOFLAGSMASK (LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP|LOCALE_RETURN_NUMBER)
58 /* current code pages */
59 static const union cptable
*ansi_cptable
;
60 static const union cptable
*oem_cptable
;
61 static const union cptable
*mac_cptable
;
62 static const union cptable
*unix_cptable
; /* NULL if UTF8 */
64 static HANDLE
NLS_RegOpenKey(HANDLE hRootKey
, LPCWSTR szKeyName
);
65 static HANDLE
NLS_RegOpenSubKey(HANDLE hRootKey
, LPCWSTR szKeyName
);
67 static const WCHAR szNlsKeyName
[] = {
68 'M','a','c','h','i','n','e','\\','S','y','s','t','e','m','\\',
69 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
70 'C','o','n','t','r','o','l','\\','N','l','s','\0'
73 /* Charset to codepage map, sorted by name. */
74 static const struct charset_entry
76 const char *charset_name
;
115 { "ISO88591", 28591 },
116 { "ISO885910", 28600 },
117 { "ISO885913", 28603 },
118 { "ISO885914", 28604 },
119 { "ISO885915", 28605 },
120 { "ISO885916", 28606 },
121 { "ISO88592", 28592 },
122 { "ISO88593", 28593 },
123 { "ISO88594", 28594 },
124 { "ISO88595", 28595 },
125 { "ISO88596", 28596 },
126 { "ISO88597", 28597 },
127 { "ISO88598", 28598 },
128 { "ISO88599", 28599 },
137 WCHAR win_name
[128]; /* Windows name ("en-US") */
138 WCHAR lang
[128]; /* language ("en") (note: buffer contains the other strings too) */
139 WCHAR
*country
; /* country ("US") */
140 WCHAR
*charset
; /* charset ("UTF-8") for Unix format only */
141 WCHAR
*script
; /* script ("Latn") for Windows format only */
142 WCHAR
*modifier
; /* modifier or sort order */
143 LCID lcid
; /* corresponding LCID */
144 int matches
; /* number of elements matching LCID (0..4) */
145 UINT codepage
; /* codepage corresponding to charset */
148 /* locale ids corresponding to the various Unix locale parameters */
149 static LCID lcid_LC_COLLATE
;
150 static LCID lcid_LC_CTYPE
;
151 static LCID lcid_LC_MESSAGES
;
152 static LCID lcid_LC_MONETARY
;
153 static LCID lcid_LC_NUMERIC
;
154 static LCID lcid_LC_TIME
;
155 static LCID lcid_LC_PAPER
;
156 static LCID lcid_LC_MEASUREMENT
;
157 static LCID lcid_LC_TELEPHONE
;
159 /* Copy Ascii string to Unicode without using codepages */
160 static inline void strcpynAtoW( WCHAR
*dst
, const char *src
, size_t n
)
162 while (n
> 1 && *src
)
164 *dst
++ = (unsigned char)*src
++;
171 /***********************************************************************
174 * Retrieve the ANSI codepage for a given locale.
176 static inline UINT
get_lcid_codepage( LCID lcid
)
179 if (!GetLocaleInfoW( lcid
, LOCALE_IDEFAULTANSICODEPAGE
|LOCALE_RETURN_NUMBER
, (WCHAR
*)&ret
,
180 sizeof(ret
)/sizeof(WCHAR
) )) ret
= 0;
185 /***********************************************************************
188 * Find the table for a given codepage, handling CP_ACP etc. pseudo-codepages
190 static const union cptable
*get_codepage_table( unsigned int codepage
)
192 const union cptable
*ret
= NULL
;
194 assert( ansi_cptable
); /* init must have been done already */
208 if (!(codepage
= kernel_get_thread_data()->code_page
)) return ansi_cptable
;
211 if (codepage
== ansi_cptable
->info
.codepage
) return ansi_cptable
;
212 if (codepage
== oem_cptable
->info
.codepage
) return oem_cptable
;
213 if (codepage
== mac_cptable
->info
.codepage
) return mac_cptable
;
214 ret
= wine_cp_get_table( codepage
);
221 /***********************************************************************
222 * charset_cmp (internal)
224 static int charset_cmp( const void *name
, const void *entry
)
226 const struct charset_entry
*charset
= (const struct charset_entry
*)entry
;
227 return strcasecmp( (const char *)name
, charset
->charset_name
);
230 /***********************************************************************
233 static UINT
find_charset( const WCHAR
*name
)
235 const struct charset_entry
*entry
;
236 char charset_name
[16];
239 /* remove punctuation characters from charset name */
240 for (i
= j
= 0; name
[i
] && j
< sizeof(charset_name
)-1; i
++)
241 if (isalnum((unsigned char)name
[i
])) charset_name
[j
++] = name
[i
];
244 entry
= bsearch( charset_name
, charset_names
,
245 sizeof(charset_names
)/sizeof(charset_names
[0]),
246 sizeof(charset_names
[0]), charset_cmp
);
247 if (entry
) return entry
->codepage
;
252 /***********************************************************************
253 * find_locale_id_callback
255 static BOOL CALLBACK
find_locale_id_callback( HMODULE hModule
, LPCWSTR type
,
256 LPCWSTR name
, WORD LangID
, LPARAM lParam
)
258 struct locale_name
*data
= (struct locale_name
*)lParam
;
261 LCID lcid
= MAKELCID( LangID
, SORT_DEFAULT
); /* FIXME: handle sort order */
263 if (PRIMARYLANGID(LangID
) == LANG_NEUTRAL
) return TRUE
; /* continue search */
265 /* first check exact name */
266 if (data
->win_name
[0] &&
267 GetLocaleInfoW( lcid
, LOCALE_SNAME
| LOCALE_NOUSEROVERRIDE
,
268 buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
270 if (!strcmpW( data
->win_name
, buffer
))
272 matches
= 4; /* everything matches */
277 if (!GetLocaleInfoW( lcid
, LOCALE_SISO639LANGNAME
| LOCALE_NOUSEROVERRIDE
,
278 buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
280 if (strcmpW( buffer
, data
->lang
)) return TRUE
;
281 matches
++; /* language name matched */
285 if (GetLocaleInfoW( lcid
, LOCALE_SISO3166CTRYNAME
|LOCALE_NOUSEROVERRIDE
,
286 buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
288 if (strcmpW( buffer
, data
->country
)) goto done
;
289 matches
++; /* country name matched */
292 else /* match default language */
294 if (SUBLANGID(LangID
) == SUBLANG_DEFAULT
) matches
++;
300 if (GetLocaleInfoW( lcid
, LOCALE_IDEFAULTUNIXCODEPAGE
| LOCALE_RETURN_NUMBER
,
301 (LPWSTR
)&unix_cp
, sizeof(unix_cp
)/sizeof(WCHAR
) ))
303 if (unix_cp
== data
->codepage
) matches
++;
307 /* FIXME: check sort order */
310 if (matches
> data
->matches
)
313 data
->matches
= matches
;
315 return (data
->matches
< 4); /* no need to continue for perfect match */
319 /***********************************************************************
322 * Parse a locale name into a struct locale_name, handling both Windows and Unix formats.
323 * Unix format is: lang[_country][.charset][@modifier]
324 * Windows format is: lang[-script][-country][_modifier]
326 static void parse_locale_name( const WCHAR
*str
, struct locale_name
*name
)
328 static const WCHAR sepW
[] = {'-','_','.','@',0};
329 static const WCHAR winsepW
[] = {'-','_',0};
330 static const WCHAR posixW
[] = {'P','O','S','I','X',0};
331 static const WCHAR cW
[] = {'C',0};
332 static const WCHAR latinW
[] = {'l','a','t','i','n',0};
333 static const WCHAR latnW
[] = {'-','L','a','t','n',0};
336 name
->country
= name
->charset
= name
->script
= name
->modifier
= NULL
;
337 name
->lcid
= MAKELCID( MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
), SORT_DEFAULT
);
340 name
->win_name
[0] = 0;
341 lstrcpynW( name
->lang
, str
, sizeof(name
->lang
)/sizeof(WCHAR
) );
343 if (!(p
= strpbrkW( name
->lang
, sepW
)))
345 if (!strcmpW( name
->lang
, posixW
) || !strcmpW( name
->lang
, cW
))
347 name
->matches
= 4; /* perfect match for default English lcid */
350 strcpyW( name
->win_name
, name
->lang
);
352 else if (*p
== '-') /* Windows format */
354 strcpyW( name
->win_name
, name
->lang
);
357 if (!(p
= strpbrkW( p
, winsepW
))) goto done
;
361 name
->script
= name
->country
;
363 if (!(p
= strpbrkW( p
, winsepW
))) goto done
;
368 else /* Unix format */
374 p
= strpbrkW( p
, sepW
+ 2 );
380 name
->codepage
= find_charset( name
->charset
);
381 p
= strchrW( p
, '@' );
389 /* rebuild a Windows name if possible */
391 if (name
->charset
) goto done
; /* can't specify charset in Windows format */
392 if (name
->modifier
&& strcmpW( name
->modifier
, latinW
))
393 goto done
; /* only Latn script supported for now */
394 strcpyW( name
->win_name
, name
->lang
);
395 if (name
->modifier
) strcatW( name
->win_name
, latnW
);
398 p
= name
->win_name
+ strlenW(name
->win_name
);
400 strcpyW( p
, name
->country
);
404 EnumResourceLanguagesW( kernel32_handle
, (LPCWSTR
)RT_STRING
, (LPCWSTR
)LOCALE_ILANGUAGE
,
405 find_locale_id_callback
, (LPARAM
)name
);
409 /***********************************************************************
410 * convert_default_lcid
412 * Get the default LCID to use for a given lctype in GetLocaleInfo.
414 static LCID
convert_default_lcid( LCID lcid
, LCTYPE lctype
)
416 if (lcid
== LOCALE_SYSTEM_DEFAULT
||
417 lcid
== LOCALE_USER_DEFAULT
||
418 lcid
== LOCALE_NEUTRAL
)
422 switch(lctype
& 0xffff)
424 case LOCALE_SSORTNAME
:
425 default_id
= lcid_LC_COLLATE
;
428 case LOCALE_FONTSIGNATURE
:
429 case LOCALE_IDEFAULTANSICODEPAGE
:
430 case LOCALE_IDEFAULTCODEPAGE
:
431 case LOCALE_IDEFAULTEBCDICCODEPAGE
:
432 case LOCALE_IDEFAULTMACCODEPAGE
:
433 case LOCALE_IDEFAULTUNIXCODEPAGE
:
434 default_id
= lcid_LC_CTYPE
;
437 case LOCALE_ICURRDIGITS
:
438 case LOCALE_ICURRENCY
:
439 case LOCALE_IINTLCURRDIGITS
:
440 case LOCALE_INEGCURR
:
441 case LOCALE_INEGSEPBYSPACE
:
442 case LOCALE_INEGSIGNPOSN
:
443 case LOCALE_INEGSYMPRECEDES
:
444 case LOCALE_IPOSSEPBYSPACE
:
445 case LOCALE_IPOSSIGNPOSN
:
446 case LOCALE_IPOSSYMPRECEDES
:
447 case LOCALE_SCURRENCY
:
448 case LOCALE_SINTLSYMBOL
:
449 case LOCALE_SMONDECIMALSEP
:
450 case LOCALE_SMONGROUPING
:
451 case LOCALE_SMONTHOUSANDSEP
:
452 case LOCALE_SNATIVECURRNAME
:
453 default_id
= lcid_LC_MONETARY
;
457 case LOCALE_IDIGITSUBSTITUTION
:
459 case LOCALE_INEGNUMBER
:
460 case LOCALE_SDECIMAL
:
461 case LOCALE_SGROUPING
:
463 case LOCALE_SNATIVEDIGITS
:
464 case LOCALE_SNEGATIVESIGN
:
465 case LOCALE_SNEGINFINITY
:
466 case LOCALE_SPOSINFINITY
:
467 case LOCALE_SPOSITIVESIGN
:
468 case LOCALE_STHOUSAND
:
469 default_id
= lcid_LC_NUMERIC
;
472 case LOCALE_ICALENDARTYPE
:
473 case LOCALE_ICENTURY
:
475 case LOCALE_IDAYLZERO
:
476 case LOCALE_IFIRSTDAYOFWEEK
:
477 case LOCALE_IFIRSTWEEKOFYEAR
:
479 case LOCALE_IMONLZERO
:
480 case LOCALE_IOPTIONALCALENDAR
:
482 case LOCALE_ITIMEMARKPOSN
:
486 case LOCALE_SABBREVDAYNAME1
:
487 case LOCALE_SABBREVDAYNAME2
:
488 case LOCALE_SABBREVDAYNAME3
:
489 case LOCALE_SABBREVDAYNAME4
:
490 case LOCALE_SABBREVDAYNAME5
:
491 case LOCALE_SABBREVDAYNAME6
:
492 case LOCALE_SABBREVDAYNAME7
:
493 case LOCALE_SABBREVMONTHNAME1
:
494 case LOCALE_SABBREVMONTHNAME2
:
495 case LOCALE_SABBREVMONTHNAME3
:
496 case LOCALE_SABBREVMONTHNAME4
:
497 case LOCALE_SABBREVMONTHNAME5
:
498 case LOCALE_SABBREVMONTHNAME6
:
499 case LOCALE_SABBREVMONTHNAME7
:
500 case LOCALE_SABBREVMONTHNAME8
:
501 case LOCALE_SABBREVMONTHNAME9
:
502 case LOCALE_SABBREVMONTHNAME10
:
503 case LOCALE_SABBREVMONTHNAME11
:
504 case LOCALE_SABBREVMONTHNAME12
:
505 case LOCALE_SABBREVMONTHNAME13
:
507 case LOCALE_SDAYNAME1
:
508 case LOCALE_SDAYNAME2
:
509 case LOCALE_SDAYNAME3
:
510 case LOCALE_SDAYNAME4
:
511 case LOCALE_SDAYNAME5
:
512 case LOCALE_SDAYNAME6
:
513 case LOCALE_SDAYNAME7
:
514 case LOCALE_SDURATION
:
515 case LOCALE_SLONGDATE
:
516 case LOCALE_SMONTHNAME1
:
517 case LOCALE_SMONTHNAME2
:
518 case LOCALE_SMONTHNAME3
:
519 case LOCALE_SMONTHNAME4
:
520 case LOCALE_SMONTHNAME5
:
521 case LOCALE_SMONTHNAME6
:
522 case LOCALE_SMONTHNAME7
:
523 case LOCALE_SMONTHNAME8
:
524 case LOCALE_SMONTHNAME9
:
525 case LOCALE_SMONTHNAME10
:
526 case LOCALE_SMONTHNAME11
:
527 case LOCALE_SMONTHNAME12
:
528 case LOCALE_SMONTHNAME13
:
529 case LOCALE_SSHORTDATE
:
530 case LOCALE_SSHORTESTDAYNAME1
:
531 case LOCALE_SSHORTESTDAYNAME2
:
532 case LOCALE_SSHORTESTDAYNAME3
:
533 case LOCALE_SSHORTESTDAYNAME4
:
534 case LOCALE_SSHORTESTDAYNAME5
:
535 case LOCALE_SSHORTESTDAYNAME6
:
536 case LOCALE_SSHORTESTDAYNAME7
:
538 case LOCALE_STIMEFORMAT
:
539 case LOCALE_SYEARMONTH
:
540 default_id
= lcid_LC_TIME
;
543 case LOCALE_IPAPERSIZE
:
544 default_id
= lcid_LC_PAPER
;
547 case LOCALE_IMEASURE
:
548 default_id
= lcid_LC_MEASUREMENT
;
551 case LOCALE_ICOUNTRY
:
552 default_id
= lcid_LC_TELEPHONE
;
555 if (default_id
) lcid
= default_id
;
557 return ConvertDefaultLocale( lcid
);
561 /***********************************************************************
562 * create_registry_key
564 * Create the Control Panel\\International registry key.
566 static inline HANDLE
create_registry_key(void)
568 static const WCHAR intlW
[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
569 'I','n','t','e','r','n','a','t','i','o','n','a','l',0};
570 OBJECT_ATTRIBUTES attr
;
571 UNICODE_STRING nameW
;
574 if (RtlOpenCurrentUser( KEY_ALL_ACCESS
, &hkey
) != STATUS_SUCCESS
) return 0;
576 attr
.Length
= sizeof(attr
);
577 attr
.RootDirectory
= hkey
;
578 attr
.ObjectName
= &nameW
;
580 attr
.SecurityDescriptor
= NULL
;
581 attr
.SecurityQualityOfService
= NULL
;
582 RtlInitUnicodeString( &nameW
, intlW
);
584 if (NtCreateKey( &hkey
, KEY_ALL_ACCESS
, &attr
, 0, NULL
, 0, NULL
) != STATUS_SUCCESS
) hkey
= 0;
585 NtClose( attr
.RootDirectory
);
590 /* update the registry settings for a given locale parameter */
591 /* return TRUE if an update was needed */
592 static BOOL
locale_update_registry( HKEY hkey
, const WCHAR
*name
, LCID lcid
,
593 const LCTYPE
*values
, UINT nb_values
)
595 static const WCHAR formatW
[] = { '%','0','8','x',0 };
597 UNICODE_STRING nameW
;
600 RtlInitUnicodeString( &nameW
, name
);
601 count
= sizeof(bufferW
);
602 if (!NtQueryValueKey(hkey
, &nameW
, KeyValuePartialInformation
, (LPBYTE
)bufferW
, count
, &count
))
604 const KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)bufferW
;
605 LPCWSTR text
= (LPCWSTR
)info
->Data
;
607 if (strtoulW( text
, NULL
, 16 ) == lcid
) return FALSE
; /* already set correctly */
608 TRACE( "updating registry, locale %s changed %s -> %08x\n",
609 debugstr_w(name
), debugstr_w(text
), lcid
);
611 else TRACE( "updating registry, locale %s changed none -> %08x\n", debugstr_w(name
), lcid
);
612 sprintfW( bufferW
, formatW
, lcid
);
613 NtSetValueKey( hkey
, &nameW
, 0, REG_SZ
, bufferW
, (strlenW(bufferW
) + 1) * sizeof(WCHAR
) );
615 for (i
= 0; i
< nb_values
; i
++)
617 GetLocaleInfoW( lcid
, values
[i
] | LOCALE_NOUSEROVERRIDE
, bufferW
,
618 sizeof(bufferW
)/sizeof(WCHAR
) );
619 SetLocaleInfoW( lcid
, values
[i
], bufferW
);
625 /***********************************************************************
626 * LOCALE_InitRegistry
628 * Update registry contents on startup if the user locale has changed.
629 * This simulates the action of the Windows control panel.
631 void LOCALE_InitRegistry(void)
633 static const WCHAR CodepageW
[] = {'C','o','d','e','p','a','g','e',0};
634 static const WCHAR acpW
[] = {'A','C','P',0};
635 static const WCHAR oemcpW
[] = {'O','E','M','C','P',0};
636 static const WCHAR maccpW
[] = {'M','A','C','C','P',0};
637 static const WCHAR localeW
[] = {'L','o','c','a','l','e',0};
638 static const WCHAR lc_ctypeW
[] = { 'L','C','_','C','T','Y','P','E',0 };
639 static const WCHAR lc_monetaryW
[] = { 'L','C','_','M','O','N','E','T','A','R','Y',0 };
640 static const WCHAR lc_numericW
[] = { 'L','C','_','N','U','M','E','R','I','C',0 };
641 static const WCHAR lc_timeW
[] = { 'L','C','_','T','I','M','E',0 };
642 static const WCHAR lc_measurementW
[] = { 'L','C','_','M','E','A','S','U','R','E','M','E','N','T',0 };
643 static const WCHAR lc_telephoneW
[] = { 'L','C','_','T','E','L','E','P','H','O','N','E',0 };
648 } update_cp_values
[] = {
649 { acpW
, LOCALE_IDEFAULTANSICODEPAGE
},
650 { oemcpW
, LOCALE_IDEFAULTCODEPAGE
},
651 { maccpW
, LOCALE_IDEFAULTMACCODEPAGE
}
653 static const LCTYPE lc_messages_values
[] = {
657 static const LCTYPE lc_monetary_values
[] = {
663 static const LCTYPE lc_numeric_values
[] = {
667 LOCALE_IDIGITSUBSTITUTION
,
668 LOCALE_SNATIVEDIGITS
};
669 static const LCTYPE lc_time_values
[] = {
678 LOCALE_ITIMEMARKPOSN
,
679 LOCALE_ICALENDARTYPE
};
680 static const LCTYPE lc_measurement_values
[] = { LOCALE_IMEASURE
};
681 static const LCTYPE lc_telephone_values
[] = { LOCALE_ICOUNTRY
};
683 UNICODE_STRING nameW
;
687 LCID lcid
= GetUserDefaultLCID();
689 if (!(hkey
= create_registry_key()))
690 return; /* don't do anything if we can't create the registry key */
692 locale_update_registry( hkey
, localeW
, lcid_LC_MESSAGES
, lc_messages_values
,
693 sizeof(lc_messages_values
)/sizeof(lc_messages_values
[0]) );
694 locale_update_registry( hkey
, lc_monetaryW
, lcid_LC_MONETARY
, lc_monetary_values
,
695 sizeof(lc_monetary_values
)/sizeof(lc_monetary_values
[0]) );
696 locale_update_registry( hkey
, lc_numericW
, lcid_LC_NUMERIC
, lc_numeric_values
,
697 sizeof(lc_numeric_values
)/sizeof(lc_numeric_values
[0]) );
698 locale_update_registry( hkey
, lc_timeW
, lcid_LC_TIME
, lc_time_values
,
699 sizeof(lc_time_values
)/sizeof(lc_time_values
[0]) );
700 locale_update_registry( hkey
, lc_measurementW
, lcid_LC_MEASUREMENT
, lc_measurement_values
,
701 sizeof(lc_measurement_values
)/sizeof(lc_measurement_values
[0]) );
702 locale_update_registry( hkey
, lc_telephoneW
, lcid_LC_TELEPHONE
, lc_telephone_values
,
703 sizeof(lc_telephone_values
)/sizeof(lc_telephone_values
[0]) );
705 if (locale_update_registry( hkey
, lc_ctypeW
, lcid_LC_CTYPE
, NULL
, 0 ))
707 HKEY nls_key
= NLS_RegOpenSubKey( NLS_RegOpenKey( 0, szNlsKeyName
), CodepageW
);
709 for (i
= 0; i
< sizeof(update_cp_values
)/sizeof(update_cp_values
[0]); i
++)
711 count
= GetLocaleInfoW( lcid
, update_cp_values
[i
].value
| LOCALE_NOUSEROVERRIDE
,
712 bufferW
, sizeof(bufferW
)/sizeof(WCHAR
) );
713 RtlInitUnicodeString( &nameW
, update_cp_values
[i
].name
);
714 NtSetValueKey( nls_key
, &nameW
, 0, REG_SZ
, bufferW
, count
* sizeof(WCHAR
) );
723 /***********************************************************************
726 static UINT
setup_unix_locales(void)
728 struct locale_name locale_name
;
729 WCHAR buffer
[128], ctype_buff
[128];
733 if ((locale
= setlocale( LC_CTYPE
, NULL
)))
735 strcpynAtoW( ctype_buff
, locale
, sizeof(ctype_buff
)/sizeof(WCHAR
) );
736 parse_locale_name( ctype_buff
, &locale_name
);
737 lcid_LC_CTYPE
= locale_name
.lcid
;
738 unix_cp
= locale_name
.codepage
;
740 if (!lcid_LC_CTYPE
) /* this one needs a default value */
741 lcid_LC_CTYPE
= MAKELCID( MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
), SORT_DEFAULT
);
743 TRACE( "got lcid %04x (%d matches) for LC_CTYPE=%s\n",
744 locale_name
.lcid
, locale_name
.matches
, debugstr_a(locale
) );
746 #define GET_UNIX_LOCALE(cat) do \
747 if ((locale = setlocale( cat, NULL ))) \
749 strcpynAtoW( buffer, locale, sizeof(buffer)/sizeof(WCHAR) ); \
750 if (!strcmpW( buffer, ctype_buff )) lcid_##cat = lcid_LC_CTYPE; \
752 parse_locale_name( buffer, &locale_name ); \
753 lcid_##cat = locale_name.lcid; \
754 TRACE( "got lcid %04x (%d matches) for " #cat "=%s\n", \
755 locale_name.lcid, locale_name.matches, debugstr_a(locale) ); \
759 GET_UNIX_LOCALE( LC_COLLATE
);
760 GET_UNIX_LOCALE( LC_MESSAGES
);
761 GET_UNIX_LOCALE( LC_MONETARY
);
762 GET_UNIX_LOCALE( LC_NUMERIC
);
763 GET_UNIX_LOCALE( LC_TIME
);
765 GET_UNIX_LOCALE( LC_PAPER
);
767 #ifdef LC_MEASUREMENT
768 GET_UNIX_LOCALE( LC_MEASUREMENT
);
771 GET_UNIX_LOCALE( LC_TELEPHONE
);
774 #undef GET_UNIX_LOCALE
780 /***********************************************************************
781 * GetUserDefaultLangID (KERNEL32.@)
783 * Get the default language Id for the current user.
789 * The current LANGID of the default language for the current user.
791 LANGID WINAPI
GetUserDefaultLangID(void)
793 return LANGIDFROMLCID(GetUserDefaultLCID());
797 /***********************************************************************
798 * GetSystemDefaultLangID (KERNEL32.@)
800 * Get the default language Id for the system.
806 * The current LANGID of the default language for the system.
808 LANGID WINAPI
GetSystemDefaultLangID(void)
810 return LANGIDFROMLCID(GetSystemDefaultLCID());
814 /***********************************************************************
815 * GetUserDefaultLCID (KERNEL32.@)
817 * Get the default locale Id for the current user.
823 * The current LCID of the default locale for the current user.
825 LCID WINAPI
GetUserDefaultLCID(void)
828 NtQueryDefaultLocale( TRUE
, &lcid
);
833 /***********************************************************************
834 * GetSystemDefaultLCID (KERNEL32.@)
836 * Get the default locale Id for the system.
842 * The current LCID of the default locale for the system.
844 LCID WINAPI
GetSystemDefaultLCID(void)
847 NtQueryDefaultLocale( FALSE
, &lcid
);
852 /***********************************************************************
853 * GetUserDefaultUILanguage (KERNEL32.@)
855 * Get the default user interface language Id for the current user.
861 * The current LANGID of the default UI language for the current user.
863 LANGID WINAPI
GetUserDefaultUILanguage(void)
866 NtQueryDefaultUILanguage( &lang
);
871 /***********************************************************************
872 * GetSystemDefaultUILanguage (KERNEL32.@)
874 * Get the default user interface language Id for the system.
880 * The current LANGID of the default UI language for the system. This is
881 * typically the same language used during the installation process.
883 LANGID WINAPI
GetSystemDefaultUILanguage(void)
886 NtQueryInstallUILanguage( &lang
);
891 /***********************************************************************
892 * LocaleNameToLCID (KERNEL32.@)
894 LCID WINAPI
LocaleNameToLCID( LPCWSTR name
, DWORD flags
)
896 struct locale_name locale_name
;
898 if (flags
) FIXME( "unsupported flags %x\n", flags
);
900 parse_locale_name( name
, &locale_name
);
902 TRACE( "found lcid %x for %s, matches %d\n",
903 locale_name
.lcid
, debugstr_w(name
), locale_name
.matches
);
905 if (!locale_name
.matches
)
906 WARN( "locale %s not recognized, defaulting to English\n", debugstr_w(name
) );
907 else if (locale_name
.matches
== 1)
908 WARN( "locale %s not recognized, defaulting to %s\n",
909 debugstr_w(name
), debugstr_w(locale_name
.lang
) );
911 return locale_name
.lcid
;
915 /***********************************************************************
916 * LCIDToLocaleName (KERNEL32.@)
918 INT WINAPI
LCIDToLocaleName( LCID lcid
, LPWSTR name
, INT count
, DWORD flags
)
920 if (flags
) FIXME( "unsupported flags %x\n", flags
);
922 return GetLocaleInfoW( lcid
, LOCALE_SNAME
| LOCALE_NOUSEROVERRIDE
, name
, count
);
926 /******************************************************************************
927 * get_locale_value_name
929 * Gets the registry value name for a given lctype.
931 static const WCHAR
*get_locale_value_name( DWORD lctype
)
933 static const WCHAR iCalendarTypeW
[] = {'i','C','a','l','e','n','d','a','r','T','y','p','e',0};
934 static const WCHAR iCountryW
[] = {'i','C','o','u','n','t','r','y',0};
935 static const WCHAR iCurrDigitsW
[] = {'i','C','u','r','r','D','i','g','i','t','s',0};
936 static const WCHAR iCurrencyW
[] = {'i','C','u','r','r','e','n','c','y',0};
937 static const WCHAR iDateW
[] = {'i','D','a','t','e',0};
938 static const WCHAR iDigitsW
[] = {'i','D','i','g','i','t','s',0};
939 static const WCHAR iFirstDayOfWeekW
[] = {'i','F','i','r','s','t','D','a','y','O','f','W','e','e','k',0};
940 static const WCHAR iFirstWeekOfYearW
[] = {'i','F','i','r','s','t','W','e','e','k','O','f','Y','e','a','r',0};
941 static const WCHAR iLDateW
[] = {'i','L','D','a','t','e',0};
942 static const WCHAR iLZeroW
[] = {'i','L','Z','e','r','o',0};
943 static const WCHAR iMeasureW
[] = {'i','M','e','a','s','u','r','e',0};
944 static const WCHAR iNegCurrW
[] = {'i','N','e','g','C','u','r','r',0};
945 static const WCHAR iNegNumberW
[] = {'i','N','e','g','N','u','m','b','e','r',0};
946 static const WCHAR iPaperSizeW
[] = {'i','P','a','p','e','r','S','i','z','e',0};
947 static const WCHAR iTLZeroW
[] = {'i','T','L','Z','e','r','o',0};
948 static const WCHAR iTimePrefixW
[] = {'i','T','i','m','e','P','r','e','f','i','x',0};
949 static const WCHAR iTimeW
[] = {'i','T','i','m','e',0};
950 static const WCHAR s1159W
[] = {'s','1','1','5','9',0};
951 static const WCHAR s2359W
[] = {'s','2','3','5','9',0};
952 static const WCHAR sCountryW
[] = {'s','C','o','u','n','t','r','y',0};
953 static const WCHAR sCurrencyW
[] = {'s','C','u','r','r','e','n','c','y',0};
954 static const WCHAR sDateW
[] = {'s','D','a','t','e',0};
955 static const WCHAR sDecimalW
[] = {'s','D','e','c','i','m','a','l',0};
956 static const WCHAR sGroupingW
[] = {'s','G','r','o','u','p','i','n','g',0};
957 static const WCHAR sLanguageW
[] = {'s','L','a','n','g','u','a','g','e',0};
958 static const WCHAR sListW
[] = {'s','L','i','s','t',0};
959 static const WCHAR sLongDateW
[] = {'s','L','o','n','g','D','a','t','e',0};
960 static const WCHAR sMonDecimalSepW
[] = {'s','M','o','n','D','e','c','i','m','a','l','S','e','p',0};
961 static const WCHAR sMonGroupingW
[] = {'s','M','o','n','G','r','o','u','p','i','n','g',0};
962 static const WCHAR sMonThousandSepW
[] = {'s','M','o','n','T','h','o','u','s','a','n','d','S','e','p',0};
963 static const WCHAR sNativeDigitsW
[] = {'s','N','a','t','i','v','e','D','i','g','i','t','s',0};
964 static const WCHAR sNegativeSignW
[] = {'s','N','e','g','a','t','i','v','e','S','i','g','n',0};
965 static const WCHAR sPositiveSignW
[] = {'s','P','o','s','i','t','i','v','e','S','i','g','n',0};
966 static const WCHAR sShortDateW
[] = {'s','S','h','o','r','t','D','a','t','e',0};
967 static const WCHAR sThousandW
[] = {'s','T','h','o','u','s','a','n','d',0};
968 static const WCHAR sTimeFormatW
[] = {'s','T','i','m','e','F','o','r','m','a','t',0};
969 static const WCHAR sTimeW
[] = {'s','T','i','m','e',0};
970 static const WCHAR sYearMonthW
[] = {'s','Y','e','a','r','M','o','n','t','h',0};
971 static const WCHAR NumShapeW
[] = {'N','u','m','s','h','a','p','e',0};
975 /* These values are used by SetLocaleInfo and GetLocaleInfo, and
976 * the values are stored in the registry, confirmed under Windows.
978 case LOCALE_ICALENDARTYPE
: return iCalendarTypeW
;
979 case LOCALE_ICURRDIGITS
: return iCurrDigitsW
;
980 case LOCALE_ICURRENCY
: return iCurrencyW
;
981 case LOCALE_IDIGITS
: return iDigitsW
;
982 case LOCALE_IFIRSTDAYOFWEEK
: return iFirstDayOfWeekW
;
983 case LOCALE_IFIRSTWEEKOFYEAR
: return iFirstWeekOfYearW
;
984 case LOCALE_ILZERO
: return iLZeroW
;
985 case LOCALE_IMEASURE
: return iMeasureW
;
986 case LOCALE_INEGCURR
: return iNegCurrW
;
987 case LOCALE_INEGNUMBER
: return iNegNumberW
;
988 case LOCALE_IPAPERSIZE
: return iPaperSizeW
;
989 case LOCALE_ITIME
: return iTimeW
;
990 case LOCALE_S1159
: return s1159W
;
991 case LOCALE_S2359
: return s2359W
;
992 case LOCALE_SCURRENCY
: return sCurrencyW
;
993 case LOCALE_SDATE
: return sDateW
;
994 case LOCALE_SDECIMAL
: return sDecimalW
;
995 case LOCALE_SGROUPING
: return sGroupingW
;
996 case LOCALE_SLIST
: return sListW
;
997 case LOCALE_SLONGDATE
: return sLongDateW
;
998 case LOCALE_SMONDECIMALSEP
: return sMonDecimalSepW
;
999 case LOCALE_SMONGROUPING
: return sMonGroupingW
;
1000 case LOCALE_SMONTHOUSANDSEP
: return sMonThousandSepW
;
1001 case LOCALE_SNEGATIVESIGN
: return sNegativeSignW
;
1002 case LOCALE_SPOSITIVESIGN
: return sPositiveSignW
;
1003 case LOCALE_SSHORTDATE
: return sShortDateW
;
1004 case LOCALE_STHOUSAND
: return sThousandW
;
1005 case LOCALE_STIME
: return sTimeW
;
1006 case LOCALE_STIMEFORMAT
: return sTimeFormatW
;
1007 case LOCALE_SYEARMONTH
: return sYearMonthW
;
1009 /* The following are not listed under MSDN as supported,
1010 * but seem to be used and also stored in the registry.
1012 case LOCALE_ICOUNTRY
: return iCountryW
;
1013 case LOCALE_IDATE
: return iDateW
;
1014 case LOCALE_ILDATE
: return iLDateW
;
1015 case LOCALE_ITLZERO
: return iTLZeroW
;
1016 case LOCALE_SCOUNTRY
: return sCountryW
;
1017 case LOCALE_SLANGUAGE
: return sLanguageW
;
1019 /* The following are used in XP and later */
1020 case LOCALE_IDIGITSUBSTITUTION
: return NumShapeW
;
1021 case LOCALE_SNATIVEDIGITS
: return sNativeDigitsW
;
1022 case LOCALE_ITIMEMARKPOSN
: return iTimePrefixW
;
1028 /******************************************************************************
1029 * get_registry_locale_info
1031 * Retrieve user-modified locale info from the registry.
1032 * Return length, 0 on error, -1 if not found.
1034 static INT
get_registry_locale_info( LPCWSTR value
, LPWSTR buffer
, INT len
)
1040 UNICODE_STRING nameW
;
1041 KEY_VALUE_PARTIAL_INFORMATION
*info
;
1042 static const int info_size
= FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION
, Data
);
1044 if (!(hkey
= create_registry_key())) return -1;
1046 RtlInitUnicodeString( &nameW
, value
);
1047 size
= info_size
+ len
* sizeof(WCHAR
);
1049 if (!(info
= HeapAlloc( GetProcessHeap(), 0, size
)))
1052 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
1056 status
= NtQueryValueKey( hkey
, &nameW
, KeyValuePartialInformation
, info
, size
, &size
);
1060 ret
= (size
- info_size
) / sizeof(WCHAR
);
1061 /* append terminating null if needed */
1062 if (!ret
|| ((WCHAR
*)info
->Data
)[ret
-1])
1064 if (ret
< len
|| !buffer
) ret
++;
1067 SetLastError( ERROR_INSUFFICIENT_BUFFER
);
1073 memcpy( buffer
, info
->Data
, (ret
-1) * sizeof(WCHAR
) );
1077 else if (status
== STATUS_BUFFER_OVERFLOW
&& !buffer
)
1079 ret
= (size
- info_size
) / sizeof(WCHAR
) + 1;
1081 else if (status
== STATUS_OBJECT_NAME_NOT_FOUND
)
1087 SetLastError( RtlNtStatusToDosError(status
) );
1091 HeapFree( GetProcessHeap(), 0, info
);
1096 /******************************************************************************
1097 * GetLocaleInfoA (KERNEL32.@)
1099 * Get information about an aspect of a locale.
1102 * lcid [I] LCID of the locale
1103 * lctype [I] LCTYPE_ flags from "winnls.h"
1104 * buffer [O] Destination for the information
1105 * len [I] Length of buffer in characters
1108 * Success: The size of the data requested. If buffer is non-NULL, it is filled
1109 * with the information.
1110 * Failure: 0. Use GetLastError() to determine the cause.
1113 * - LOCALE_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
1114 * - The string returned is NUL terminated, except for LOCALE_FONTSIGNATURE,
1115 * which is a bit string.
1117 INT WINAPI
GetLocaleInfoA( LCID lcid
, LCTYPE lctype
, LPSTR buffer
, INT len
)
1122 TRACE( "(lcid=0x%x,lctype=0x%x,%p,%d)\n", lcid
, lctype
, buffer
, len
);
1124 if (len
< 0 || (len
&& !buffer
))
1126 SetLastError( ERROR_INVALID_PARAMETER
);
1129 if (!len
) buffer
= NULL
;
1131 if (!(lenW
= GetLocaleInfoW( lcid
, lctype
, NULL
, 0 ))) return 0;
1133 if (!(bufferW
= HeapAlloc( GetProcessHeap(), 0, lenW
* sizeof(WCHAR
) )))
1135 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
1138 if ((ret
= GetLocaleInfoW( lcid
, lctype
, bufferW
, lenW
)))
1140 if ((lctype
& LOCALE_RETURN_NUMBER
) ||
1141 ((lctype
& ~LOCALE_LOCALEINFOFLAGSMASK
) == LOCALE_FONTSIGNATURE
))
1143 /* it's not an ASCII string, just bytes */
1144 ret
*= sizeof(WCHAR
);
1147 if (ret
<= len
) memcpy( buffer
, bufferW
, ret
);
1150 SetLastError( ERROR_INSUFFICIENT_BUFFER
);
1157 UINT codepage
= CP_ACP
;
1158 if (!(lctype
& LOCALE_USE_CP_ACP
)) codepage
= get_lcid_codepage( lcid
);
1159 ret
= WideCharToMultiByte( codepage
, 0, bufferW
, ret
, buffer
, len
, NULL
, NULL
);
1162 HeapFree( GetProcessHeap(), 0, bufferW
);
1167 /******************************************************************************
1168 * GetLocaleInfoW (KERNEL32.@)
1170 * See GetLocaleInfoA.
1172 INT WINAPI
GetLocaleInfoW( LCID lcid
, LCTYPE lctype
, LPWSTR buffer
, INT len
)
1182 if (len
< 0 || (len
&& !buffer
))
1184 SetLastError( ERROR_INVALID_PARAMETER
);
1187 if (!len
) buffer
= NULL
;
1189 lcid
= convert_default_lcid( lcid
, lctype
);
1191 lcflags
= lctype
& LOCALE_LOCALEINFOFLAGSMASK
;
1194 TRACE( "(lcid=0x%x,lctype=0x%x,%p,%d)\n", lcid
, lctype
, buffer
, len
);
1196 /* first check for overrides in the registry */
1198 if (!(lcflags
& LOCALE_NOUSEROVERRIDE
) &&
1199 lcid
== convert_default_lcid( LOCALE_USER_DEFAULT
, lctype
))
1201 const WCHAR
*value
= get_locale_value_name(lctype
);
1205 if (lcflags
& LOCALE_RETURN_NUMBER
)
1208 ret
= get_registry_locale_info( value
, tmp
, sizeof(tmp
)/sizeof(WCHAR
) );
1212 UINT number
= strtolW( tmp
, &end
, 10 );
1213 if (*end
) /* invalid number */
1215 SetLastError( ERROR_INVALID_FLAGS
);
1218 ret
= sizeof(UINT
)/sizeof(WCHAR
);
1219 if (!buffer
) return ret
;
1222 SetLastError( ERROR_INSUFFICIENT_BUFFER
);
1225 memcpy( buffer
, &number
, sizeof(number
) );
1228 else ret
= get_registry_locale_info( value
, buffer
, len
);
1230 if (ret
!= -1) return ret
;
1234 /* now load it from kernel resources */
1236 lang_id
= LANGIDFROMLCID( lcid
);
1238 /* replace SUBLANG_NEUTRAL by SUBLANG_DEFAULT */
1239 if (SUBLANGID(lang_id
) == SUBLANG_NEUTRAL
)
1240 lang_id
= MAKELANGID(PRIMARYLANGID(lang_id
), SUBLANG_DEFAULT
);
1242 if (!(hrsrc
= FindResourceExW( kernel32_handle
, (LPWSTR
)RT_STRING
,
1243 ULongToPtr((lctype
>> 4) + 1), lang_id
)))
1245 SetLastError( ERROR_INVALID_FLAGS
); /* no such lctype */
1248 if (!(hmem
= LoadResource( kernel32_handle
, hrsrc
)))
1251 p
= LockResource( hmem
);
1252 for (i
= 0; i
< (lctype
& 0x0f); i
++) p
+= *p
+ 1;
1254 if (lcflags
& LOCALE_RETURN_NUMBER
) ret
= sizeof(UINT
)/sizeof(WCHAR
);
1255 else ret
= (lctype
== LOCALE_FONTSIGNATURE
) ? *p
: *p
+ 1;
1257 if (!buffer
) return ret
;
1261 SetLastError( ERROR_INSUFFICIENT_BUFFER
);
1265 if (lcflags
& LOCALE_RETURN_NUMBER
)
1268 WCHAR
*end
, *tmp
= HeapAlloc( GetProcessHeap(), 0, (*p
+ 1) * sizeof(WCHAR
) );
1270 memcpy( tmp
, p
+ 1, *p
* sizeof(WCHAR
) );
1272 number
= strtolW( tmp
, &end
, 10 );
1274 memcpy( buffer
, &number
, sizeof(number
) );
1275 else /* invalid number */
1277 SetLastError( ERROR_INVALID_FLAGS
);
1280 HeapFree( GetProcessHeap(), 0, tmp
);
1282 TRACE( "(lcid=0x%x,lctype=0x%x,%p,%d) returning number %d\n",
1283 lcid
, lctype
, buffer
, len
, number
);
1287 memcpy( buffer
, p
+ 1, *p
* sizeof(WCHAR
) );
1288 if (lctype
!= LOCALE_FONTSIGNATURE
) buffer
[ret
-1] = 0;
1290 TRACE( "(lcid=0x%x,lctype=0x%x,%p,%d) returning %d %s\n",
1291 lcid
, lctype
, buffer
, len
, ret
, debugstr_w(buffer
) );
1297 /******************************************************************************
1298 * SetLocaleInfoA [KERNEL32.@]
1300 * Set information about an aspect of a locale.
1303 * lcid [I] LCID of the locale
1304 * lctype [I] LCTYPE_ flags from "winnls.h"
1305 * data [I] Information to set
1308 * Success: TRUE. The information given will be returned by GetLocaleInfoA()
1309 * whenever it is called without LOCALE_NOUSEROVERRIDE.
1310 * Failure: FALSE. Use GetLastError() to determine the cause.
1313 * - Values are only be set for the current user locale; the system locale
1314 * settings cannot be changed.
1315 * - Any settings changed by this call are lost when the locale is changed by
1316 * the control panel (in Wine, this happens every time you change LANG).
1317 * - The native implementation of this function does not check that lcid matches
1318 * the current user locale, and simply sets the new values. Wine warns you in
1319 * this case, but behaves the same.
1321 BOOL WINAPI
SetLocaleInfoA(LCID lcid
, LCTYPE lctype
, LPCSTR data
)
1323 UINT codepage
= CP_ACP
;
1328 if (!(lctype
& LOCALE_USE_CP_ACP
)) codepage
= get_lcid_codepage( lcid
);
1332 SetLastError( ERROR_INVALID_PARAMETER
);
1335 len
= MultiByteToWideChar( codepage
, 0, data
, -1, NULL
, 0 );
1336 if (!(strW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) )))
1338 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
1341 MultiByteToWideChar( codepage
, 0, data
, -1, strW
, len
);
1342 ret
= SetLocaleInfoW( lcid
, lctype
, strW
);
1343 HeapFree( GetProcessHeap(), 0, strW
);
1348 /******************************************************************************
1349 * SetLocaleInfoW (KERNEL32.@)
1351 * See SetLocaleInfoA.
1353 BOOL WINAPI
SetLocaleInfoW( LCID lcid
, LCTYPE lctype
, LPCWSTR data
)
1356 static const WCHAR intlW
[] = {'i','n','t','l',0 };
1357 UNICODE_STRING valueW
;
1362 value
= get_locale_value_name( lctype
);
1364 if (!data
|| !value
)
1366 SetLastError( ERROR_INVALID_PARAMETER
);
1370 if (lctype
== LOCALE_IDATE
|| lctype
== LOCALE_ILDATE
)
1372 SetLastError( ERROR_INVALID_FLAGS
);
1376 TRACE("setting %x (%s) to %s\n", lctype
, debugstr_w(value
), debugstr_w(data
) );
1378 /* FIXME: should check that data to set is sane */
1380 /* FIXME: profile functions should map to registry */
1381 WriteProfileStringW( intlW
, value
, data
);
1383 if (!(hkey
= create_registry_key())) return FALSE
;
1384 RtlInitUnicodeString( &valueW
, value
);
1385 status
= NtSetValueKey( hkey
, &valueW
, 0, REG_SZ
, data
, (strlenW(data
)+1)*sizeof(WCHAR
) );
1387 if (lctype
== LOCALE_SSHORTDATE
|| lctype
== LOCALE_SLONGDATE
)
1389 /* Set I-value from S value */
1390 WCHAR
*lpD
, *lpM
, *lpY
;
1393 lpD
= strrchrW(data
, 'd');
1394 lpM
= strrchrW(data
, 'M');
1395 lpY
= strrchrW(data
, 'y');
1399 szBuff
[0] = '1'; /* D-M-Y */
1404 szBuff
[0] = '2'; /* Y-M-D */
1406 szBuff
[0] = '0'; /* M-D-Y */
1411 if (lctype
== LOCALE_SSHORTDATE
)
1412 lctype
= LOCALE_IDATE
;
1414 lctype
= LOCALE_ILDATE
;
1416 value
= get_locale_value_name( lctype
);
1418 WriteProfileStringW( intlW
, value
, szBuff
);
1420 RtlInitUnicodeString( &valueW
, value
);
1421 status
= NtSetValueKey( hkey
, &valueW
, 0, REG_SZ
, szBuff
, sizeof(szBuff
) );
1426 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
1431 /******************************************************************************
1432 * GetACP (KERNEL32.@)
1434 * Get the current Ansi code page Id for the system.
1440 * The current Ansi code page identifier for the system.
1442 UINT WINAPI
GetACP(void)
1444 assert( ansi_cptable
);
1445 return ansi_cptable
->info
.codepage
;
1449 /******************************************************************************
1450 * SetCPGlobal (KERNEL32.@)
1452 * Set the current Ansi code page Id for the system.
1455 * acp [I] code page ID to be the new ACP.
1460 UINT WINAPI
SetCPGlobal( UINT acp
)
1462 UINT ret
= GetACP();
1463 const union cptable
*new_cptable
= wine_cp_get_table( acp
);
1465 if (new_cptable
) ansi_cptable
= new_cptable
;
1470 /***********************************************************************
1471 * GetOEMCP (KERNEL32.@)
1473 * Get the current OEM code page Id for the system.
1479 * The current OEM code page identifier for the system.
1481 UINT WINAPI
GetOEMCP(void)
1483 assert( oem_cptable
);
1484 return oem_cptable
->info
.codepage
;
1488 /***********************************************************************
1489 * IsValidCodePage (KERNEL32.@)
1491 * Determine if a given code page identifier is valid.
1494 * codepage [I] Code page Id to verify.
1497 * TRUE, If codepage is valid and available on the system,
1500 BOOL WINAPI
IsValidCodePage( UINT codepage
)
1507 return wine_cp_get_table( codepage
) != NULL
;
1512 /***********************************************************************
1513 * IsDBCSLeadByteEx (KERNEL32.@)
1515 * Determine if a character is a lead byte in a given code page.
1518 * codepage [I] Code page for the test.
1519 * testchar [I] Character to test
1522 * TRUE, if testchar is a lead byte in codepage,
1525 BOOL WINAPI
IsDBCSLeadByteEx( UINT codepage
, BYTE testchar
)
1527 const union cptable
*table
= get_codepage_table( codepage
);
1528 return table
&& wine_is_dbcs_leadbyte( table
, testchar
);
1532 /***********************************************************************
1533 * IsDBCSLeadByte (KERNEL32.@)
1534 * IsDBCSLeadByte (KERNEL.207)
1536 * Determine if a character is a lead byte.
1539 * testchar [I] Character to test
1542 * TRUE, if testchar is a lead byte in the Ansii code page,
1545 BOOL WINAPI
IsDBCSLeadByte( BYTE testchar
)
1547 if (!ansi_cptable
) return FALSE
;
1548 return wine_is_dbcs_leadbyte( ansi_cptable
, testchar
);
1552 /***********************************************************************
1553 * GetCPInfo (KERNEL32.@)
1555 * Get information about a code page.
1558 * codepage [I] Code page number
1559 * cpinfo [O] Destination for code page information
1562 * Success: TRUE. cpinfo is updated with the information about codepage.
1563 * Failure: FALSE, if codepage is invalid or cpinfo is NULL.
1565 BOOL WINAPI
GetCPInfo( UINT codepage
, LPCPINFO cpinfo
)
1567 const union cptable
*table
;
1571 SetLastError( ERROR_INVALID_PARAMETER
);
1575 if (!(table
= get_codepage_table( codepage
)))
1581 cpinfo
->DefaultChar
[0] = 0x3f;
1582 cpinfo
->DefaultChar
[1] = 0;
1583 cpinfo
->LeadByte
[0] = cpinfo
->LeadByte
[1] = 0;
1584 cpinfo
->MaxCharSize
= (codepage
== CP_UTF7
) ? 5 : 4;
1588 SetLastError( ERROR_INVALID_PARAMETER
);
1591 if (table
->info
.def_char
& 0xff00)
1593 cpinfo
->DefaultChar
[0] = (table
->info
.def_char
& 0xff00) >> 8;
1594 cpinfo
->DefaultChar
[1] = table
->info
.def_char
& 0x00ff;
1598 cpinfo
->DefaultChar
[0] = table
->info
.def_char
& 0xff;
1599 cpinfo
->DefaultChar
[1] = 0;
1601 if ((cpinfo
->MaxCharSize
= table
->info
.char_size
) == 2)
1602 memcpy( cpinfo
->LeadByte
, table
->dbcs
.lead_bytes
, sizeof(cpinfo
->LeadByte
) );
1604 cpinfo
->LeadByte
[0] = cpinfo
->LeadByte
[1] = 0;
1609 /***********************************************************************
1610 * GetCPInfoExA (KERNEL32.@)
1612 * Get extended information about a code page.
1615 * codepage [I] Code page number
1616 * dwFlags [I] Reserved, must to 0.
1617 * cpinfo [O] Destination for code page information
1620 * Success: TRUE. cpinfo is updated with the information about codepage.
1621 * Failure: FALSE, if codepage is invalid or cpinfo is NULL.
1623 BOOL WINAPI
GetCPInfoExA( UINT codepage
, DWORD dwFlags
, LPCPINFOEXA cpinfo
)
1627 if (!GetCPInfoExW( codepage
, dwFlags
, &cpinfoW
))
1630 /* the layout is the same except for CodePageName */
1631 memcpy(cpinfo
, &cpinfoW
, sizeof(CPINFOEXA
));
1632 WideCharToMultiByte(CP_ACP
, 0, cpinfoW
.CodePageName
, -1, cpinfo
->CodePageName
, sizeof(cpinfo
->CodePageName
), NULL
, NULL
);
1636 /***********************************************************************
1637 * GetCPInfoExW (KERNEL32.@)
1639 * Unicode version of GetCPInfoExA.
1641 BOOL WINAPI
GetCPInfoExW( UINT codepage
, DWORD dwFlags
, LPCPINFOEXW cpinfo
)
1643 if (!GetCPInfo( codepage
, (LPCPINFO
)cpinfo
))
1650 static const WCHAR utf7
[] = {'U','n','i','c','o','d','e',' ','(','U','T','F','-','7',')',0};
1652 cpinfo
->CodePage
= CP_UTF7
;
1653 cpinfo
->UnicodeDefaultChar
= 0x3f;
1654 strcpyW(cpinfo
->CodePageName
, utf7
);
1660 static const WCHAR utf8
[] = {'U','n','i','c','o','d','e',' ','(','U','T','F','-','8',')',0};
1662 cpinfo
->CodePage
= CP_UTF8
;
1663 cpinfo
->UnicodeDefaultChar
= 0x3f;
1664 strcpyW(cpinfo
->CodePageName
, utf8
);
1670 const union cptable
*table
= get_codepage_table( codepage
);
1672 cpinfo
->CodePage
= table
->info
.codepage
;
1673 cpinfo
->UnicodeDefaultChar
= table
->info
.def_unicode_char
;
1674 MultiByteToWideChar( CP_ACP
, 0, table
->info
.name
, -1, cpinfo
->CodePageName
,
1675 sizeof(cpinfo
->CodePageName
)/sizeof(WCHAR
));
1682 /***********************************************************************
1683 * EnumSystemCodePagesA (KERNEL32.@)
1685 * Call a user defined function for every code page installed on the system.
1688 * lpfnCodePageEnum [I] User CODEPAGE_ENUMPROC to call with each found code page
1689 * flags [I] Reserved, set to 0.
1692 * TRUE, If all code pages have been enumerated, or
1693 * FALSE if lpfnCodePageEnum returned FALSE to stop the enumeration.
1695 BOOL WINAPI
EnumSystemCodePagesA( CODEPAGE_ENUMPROCA lpfnCodePageEnum
, DWORD flags
)
1697 const union cptable
*table
;
1703 if (!(table
= wine_cp_enum_table( index
++ ))) break;
1704 sprintf( buffer
, "%d", table
->info
.codepage
);
1705 if (!lpfnCodePageEnum( buffer
)) break;
1711 /***********************************************************************
1712 * EnumSystemCodePagesW (KERNEL32.@)
1714 * See EnumSystemCodePagesA.
1716 BOOL WINAPI
EnumSystemCodePagesW( CODEPAGE_ENUMPROCW lpfnCodePageEnum
, DWORD flags
)
1718 const union cptable
*table
;
1719 WCHAR buffer
[10], *p
;
1720 int page
, index
= 0;
1724 if (!(table
= wine_cp_enum_table( index
++ ))) break;
1725 p
= buffer
+ sizeof(buffer
)/sizeof(WCHAR
);
1727 page
= table
->info
.codepage
;
1730 *--p
= '0' + (page
% 10);
1733 if (!lpfnCodePageEnum( p
)) break;
1739 /***********************************************************************
1740 * MultiByteToWideChar (KERNEL32.@)
1742 * Convert a multibyte character string into a Unicode string.
1745 * page [I] Codepage character set to convert from
1746 * flags [I] Character mapping flags
1747 * src [I] Source string buffer
1748 * srclen [I] Length of src (in bytes), or -1 if src is NUL terminated
1749 * dst [O] Destination buffer
1750 * dstlen [I] Length of dst (in WCHARs), or 0 to compute the required length
1753 * Success: If dstlen > 0, the number of characters written to dst.
1754 * If dstlen == 0, the number of characters needed to perform the
1755 * conversion. In both cases the count includes the terminating NUL.
1756 * Failure: 0. Use GetLastError() to determine the cause. Possible errors are
1757 * ERROR_INSUFFICIENT_BUFFER, if not enough space is available in dst
1758 * and dstlen != 0; ERROR_INVALID_PARAMETER, if an invalid parameter
1759 * is passed, and ERROR_NO_UNICODE_TRANSLATION if no translation is
1762 INT WINAPI
MultiByteToWideChar( UINT page
, DWORD flags
, LPCSTR src
, INT srclen
,
1763 LPWSTR dst
, INT dstlen
)
1765 const union cptable
*table
;
1768 if (!src
|| (!dst
&& dstlen
))
1770 SetLastError( ERROR_INVALID_PARAMETER
);
1774 if (srclen
< 0) srclen
= strlen(src
) + 1;
1781 SetLastError( ERROR_INVALID_PARAMETER
);
1784 ret
= wine_cpsymbol_mbstowcs( src
, srclen
, dst
, dstlen
);
1787 FIXME("UTF-7 not supported\n");
1788 SetLastError( ERROR_CALL_NOT_IMPLEMENTED
);
1793 ret
= wine_cp_mbstowcs( unix_cptable
, flags
, src
, srclen
, dst
, dstlen
);
1798 ret
= wine_utf8_mbstowcs( flags
, src
, srclen
, dst
, dstlen
);
1801 if (!(table
= get_codepage_table( page
)))
1803 SetLastError( ERROR_INVALID_PARAMETER
);
1806 ret
= wine_cp_mbstowcs( table
, flags
, src
, srclen
, dst
, dstlen
);
1814 case -1: SetLastError( ERROR_INSUFFICIENT_BUFFER
); break;
1815 case -2: SetLastError( ERROR_NO_UNICODE_TRANSLATION
); break;
1819 TRACE("cp %d %s -> %s, ret = %d\n",
1820 page
, debugstr_an(src
, srclen
), debugstr_wn(dst
, ret
), ret
);
1825 /***********************************************************************
1826 * WideCharToMultiByte (KERNEL32.@)
1828 * Convert a Unicode character string into a multibyte string.
1831 * page [I] Code page character set to convert to
1832 * flags [I] Mapping Flags (MB_ constants from "winnls.h").
1833 * src [I] Source string buffer
1834 * srclen [I] Length of src (in WCHARs), or -1 if src is NUL terminated
1835 * dst [O] Destination buffer
1836 * dstlen [I] Length of dst (in bytes), or 0 to compute the required length
1837 * defchar [I] Default character to use for conversion if no exact
1838 * conversion can be made
1839 * used [O] Set if default character was used in the conversion
1842 * Success: If dstlen > 0, the number of characters written to dst.
1843 * If dstlen == 0, number of characters needed to perform the
1844 * conversion. In both cases the count includes the terminating NUL.
1845 * Failure: 0. Use GetLastError() to determine the cause. Possible errors are
1846 * ERROR_INSUFFICIENT_BUFFER, if not enough space is available in dst
1847 * and dstlen != 0, and ERROR_INVALID_PARAMETER, if an invalid
1848 * parameter was given.
1850 INT WINAPI
WideCharToMultiByte( UINT page
, DWORD flags
, LPCWSTR src
, INT srclen
,
1851 LPSTR dst
, INT dstlen
, LPCSTR defchar
, BOOL
*used
)
1853 const union cptable
*table
;
1856 if (!src
|| (!dst
&& dstlen
))
1858 SetLastError( ERROR_INVALID_PARAMETER
);
1862 if (srclen
< 0) srclen
= strlenW(src
) + 1;
1867 if( flags
|| defchar
|| used
)
1869 SetLastError( ERROR_INVALID_PARAMETER
);
1872 ret
= wine_cpsymbol_wcstombs( src
, srclen
, dst
, dstlen
);
1875 FIXME("UTF-7 not supported\n");
1876 SetLastError( ERROR_CALL_NOT_IMPLEMENTED
);
1881 ret
= wine_cp_wcstombs( unix_cptable
, flags
, src
, srclen
, dst
, dstlen
,
1882 defchar
, used
? &used_tmp
: NULL
);
1887 if (used
) *used
= FALSE
; /* all chars are valid for UTF-8 */
1888 ret
= wine_utf8_wcstombs( flags
, src
, srclen
, dst
, dstlen
);
1891 if (!(table
= get_codepage_table( page
)))
1893 SetLastError( ERROR_INVALID_PARAMETER
);
1896 ret
= wine_cp_wcstombs( table
, flags
, src
, srclen
, dst
, dstlen
,
1897 defchar
, used
? &used_tmp
: NULL
);
1898 if (used
) *used
= used_tmp
;
1906 case -1: SetLastError( ERROR_INSUFFICIENT_BUFFER
); break;
1907 case -2: SetLastError( ERROR_NO_UNICODE_TRANSLATION
); break;
1911 TRACE("cp %d %s -> %s, ret = %d\n",
1912 page
, debugstr_wn(src
, srclen
), debugstr_an(dst
, ret
), ret
);
1917 /***********************************************************************
1918 * GetThreadLocale (KERNEL32.@)
1920 * Get the current threads locale.
1926 * The LCID currently assocated with the calling thread.
1928 LCID WINAPI
GetThreadLocale(void)
1930 LCID ret
= NtCurrentTeb()->CurrentLocale
;
1931 if (!ret
) NtCurrentTeb()->CurrentLocale
= ret
= GetUserDefaultLCID();
1935 /**********************************************************************
1936 * SetThreadLocale (KERNEL32.@)
1938 * Set the current threads locale.
1941 * lcid [I] LCID of the locale to set
1944 * Success: TRUE. The threads locale is set to lcid.
1945 * Failure: FALSE. Use GetLastError() to determine the cause.
1947 BOOL WINAPI
SetThreadLocale( LCID lcid
)
1949 TRACE("(0x%04X)\n", lcid
);
1951 lcid
= ConvertDefaultLocale(lcid
);
1953 if (lcid
!= GetThreadLocale())
1955 if (!IsValidLocale(lcid
, LCID_SUPPORTED
))
1957 SetLastError(ERROR_INVALID_PARAMETER
);
1961 NtCurrentTeb()->CurrentLocale
= lcid
;
1962 kernel_get_thread_data()->code_page
= get_lcid_codepage( lcid
);
1967 /**********************************************************************
1968 * SetThreadUILanguage (KERNEL32.@)
1970 * Set the current threads UI language.
1973 * langid [I] LANGID of the language to set, or 0 to use
1974 * the available language which is best supported
1975 * for console applications
1978 * Success: The return value is the same as the input value.
1979 * Failure: The return value differs from the input value.
1980 * Use GetLastError() to determine the cause.
1982 LANGID WINAPI
SetThreadUILanguage( LANGID langid
)
1984 TRACE("(0x%04x) stub - returning success\n", langid
);
1988 /******************************************************************************
1989 * ConvertDefaultLocale (KERNEL32.@)
1991 * Convert a default locale identifier into a real identifier.
1994 * lcid [I] LCID identifier of the locale to convert
1997 * lcid unchanged, if not a default locale or its sublanguage is
1998 * not SUBLANG_NEUTRAL.
1999 * GetSystemDefaultLCID(), if lcid == LOCALE_SYSTEM_DEFAULT.
2000 * GetUserDefaultLCID(), if lcid == LOCALE_USER_DEFAULT or LOCALE_NEUTRAL.
2001 * Otherwise, lcid with sublanguage changed to SUBLANG_DEFAULT.
2003 LCID WINAPI
ConvertDefaultLocale( LCID lcid
)
2009 case LOCALE_SYSTEM_DEFAULT
:
2010 lcid
= GetSystemDefaultLCID();
2012 case LOCALE_USER_DEFAULT
:
2013 case LOCALE_NEUTRAL
:
2014 lcid
= GetUserDefaultLCID();
2017 /* Replace SUBLANG_NEUTRAL with SUBLANG_DEFAULT */
2018 langid
= LANGIDFROMLCID(lcid
);
2019 if (SUBLANGID(langid
) == SUBLANG_NEUTRAL
)
2021 langid
= MAKELANGID(PRIMARYLANGID(langid
), SUBLANG_DEFAULT
);
2022 lcid
= MAKELCID(langid
, SORTIDFROMLCID(lcid
));
2029 /******************************************************************************
2030 * IsValidLocale (KERNEL32.@)
2032 * Determine if a locale is valid.
2035 * lcid [I] LCID of the locale to check
2036 * flags [I] LCID_SUPPORTED = Valid, LCID_INSTALLED = Valid and installed on the system
2039 * TRUE, if lcid is valid,
2043 * Wine does not currently make the distinction between supported and installed. All
2044 * languages supported are installed by default.
2046 BOOL WINAPI
IsValidLocale( LCID lcid
, DWORD flags
)
2048 /* check if language is registered in the kernel32 resources */
2049 return FindResourceExW( kernel32_handle
, (LPWSTR
)RT_STRING
,
2050 (LPCWSTR
)LOCALE_ILANGUAGE
, LANGIDFROMLCID(lcid
)) != 0;
2054 static BOOL CALLBACK
enum_lang_proc_a( HMODULE hModule
, LPCSTR type
,
2055 LPCSTR name
, WORD LangID
, LONG_PTR lParam
)
2057 LOCALE_ENUMPROCA lpfnLocaleEnum
= (LOCALE_ENUMPROCA
)lParam
;
2060 sprintf(buf
, "%08x", (UINT
)LangID
);
2061 return lpfnLocaleEnum( buf
);
2064 static BOOL CALLBACK
enum_lang_proc_w( HMODULE hModule
, LPCWSTR type
,
2065 LPCWSTR name
, WORD LangID
, LONG_PTR lParam
)
2067 static const WCHAR formatW
[] = {'%','0','8','x',0};
2068 LOCALE_ENUMPROCW lpfnLocaleEnum
= (LOCALE_ENUMPROCW
)lParam
;
2070 sprintfW( buf
, formatW
, (UINT
)LangID
);
2071 return lpfnLocaleEnum( buf
);
2074 /******************************************************************************
2075 * EnumSystemLocalesA (KERNEL32.@)
2077 * Call a users function for each locale available on the system.
2080 * lpfnLocaleEnum [I] Callback function to call for each locale
2081 * dwFlags [I] LOCALE_SUPPORTED=All supported, LOCALE_INSTALLED=Installed only
2085 * Failure: FALSE. Use GetLastError() to determine the cause.
2087 BOOL WINAPI
EnumSystemLocalesA( LOCALE_ENUMPROCA lpfnLocaleEnum
, DWORD dwFlags
)
2089 TRACE("(%p,%08x)\n", lpfnLocaleEnum
, dwFlags
);
2090 EnumResourceLanguagesA( kernel32_handle
, (LPSTR
)RT_STRING
,
2091 (LPCSTR
)LOCALE_ILANGUAGE
, enum_lang_proc_a
,
2092 (LONG_PTR
)lpfnLocaleEnum
);
2097 /******************************************************************************
2098 * EnumSystemLocalesW (KERNEL32.@)
2100 * See EnumSystemLocalesA.
2102 BOOL WINAPI
EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum
, DWORD dwFlags
)
2104 TRACE("(%p,%08x)\n", lpfnLocaleEnum
, dwFlags
);
2105 EnumResourceLanguagesW( kernel32_handle
, (LPWSTR
)RT_STRING
,
2106 (LPCWSTR
)LOCALE_ILANGUAGE
, enum_lang_proc_w
,
2107 (LONG_PTR
)lpfnLocaleEnum
);
2112 /***********************************************************************
2113 * VerLanguageNameA (KERNEL32.@)
2115 * Get the name of a language.
2118 * wLang [I] LANGID of the language
2119 * szLang [O] Destination for the language name
2122 * Success: The size of the language name. If szLang is non-NULL, it is filled
2124 * Failure: 0. Use GetLastError() to determine the cause.
2127 DWORD WINAPI
VerLanguageNameA( UINT wLang
, LPSTR szLang
, UINT nSize
)
2129 return GetLocaleInfoA( MAKELCID(wLang
, SORT_DEFAULT
), LOCALE_SENGLANGUAGE
, szLang
, nSize
);
2133 /***********************************************************************
2134 * VerLanguageNameW (KERNEL32.@)
2136 * See VerLanguageNameA.
2138 DWORD WINAPI
VerLanguageNameW( UINT wLang
, LPWSTR szLang
, UINT nSize
)
2140 return GetLocaleInfoW( MAKELCID(wLang
, SORT_DEFAULT
), LOCALE_SENGLANGUAGE
, szLang
, nSize
);
2144 /******************************************************************************
2145 * GetStringTypeW (KERNEL32.@)
2147 * See GetStringTypeA.
2149 BOOL WINAPI
GetStringTypeW( DWORD type
, LPCWSTR src
, INT count
, LPWORD chartype
)
2151 if (count
== -1) count
= strlenW(src
) + 1;
2155 while (count
--) *chartype
++ = get_char_typeW( *src
++ ) & 0xfff;
2158 while (count
--) *chartype
++ = get_char_typeW( *src
++ ) >> 12;
2162 WARN("CT_CTYPE3: semi-stub.\n");
2166 WORD type1
, type3
= 0; /* C3_NOTAPPLICABLE */
2168 type1
= get_char_typeW( *src
++ ) & 0xfff;
2169 /* try to construct type3 from type1 */
2170 if(type1
& C1_SPACE
) type3
|= C3_SYMBOL
;
2171 if(type1
& C1_ALPHA
) type3
|= C3_ALPHA
;
2172 if ((c
>=0x30A0)&&(c
<=0x30FF)) type3
|= C3_KATAKANA
;
2173 if ((c
>=0x3040)&&(c
<=0x309F)) type3
|= C3_HIRAGANA
;
2174 if ((c
>=0x4E00)&&(c
<=0x9FAF)) type3
|= C3_IDEOGRAPH
;
2175 if ((c
>=0x0600)&&(c
<=0x06FF)) type3
|= C3_KASHIDA
;
2176 if ((c
>=0x3000)&&(c
<=0x303F)) type3
|= C3_SYMBOL
;
2178 if ((c
>=0xFF00)&&(c
<=0xFF60)) type3
|= C3_FULLWIDTH
;
2179 if ((c
>=0xFF00)&&(c
<=0xFF20)) type3
|= C3_SYMBOL
;
2180 if ((c
>=0xFF3B)&&(c
<=0xFF40)) type3
|= C3_SYMBOL
;
2181 if ((c
>=0xFF5B)&&(c
<=0xFF60)) type3
|= C3_SYMBOL
;
2182 if ((c
>=0xFF21)&&(c
<=0xFF3A)) type3
|= C3_ALPHA
;
2183 if ((c
>=0xFF41)&&(c
<=0xFF5A)) type3
|= C3_ALPHA
;
2184 if ((c
>=0xFFE0)&&(c
<=0xFFE6)) type3
|= C3_FULLWIDTH
;
2185 if ((c
>=0xFFE0)&&(c
<=0xFFE6)) type3
|= C3_SYMBOL
;
2187 if ((c
>=0xFF61)&&(c
<=0xFFDC)) type3
|= C3_HALFWIDTH
;
2188 if ((c
>=0xFF61)&&(c
<=0xFF64)) type3
|= C3_SYMBOL
;
2189 if ((c
>=0xFF65)&&(c
<=0xFF9F)) type3
|= C3_KATAKANA
;
2190 if ((c
>=0xFF65)&&(c
<=0xFF9F)) type3
|= C3_ALPHA
;
2191 if ((c
>=0xFFE8)&&(c
<=0xFFEE)) type3
|= C3_HALFWIDTH
;
2192 if ((c
>=0xFFE8)&&(c
<=0xFFEE)) type3
|= C3_SYMBOL
;
2193 *chartype
++ = type3
;
2198 SetLastError( ERROR_INVALID_PARAMETER
);
2205 /******************************************************************************
2206 * GetStringTypeExW (KERNEL32.@)
2208 * See GetStringTypeExA.
2210 BOOL WINAPI
GetStringTypeExW( LCID locale
, DWORD type
, LPCWSTR src
, INT count
, LPWORD chartype
)
2212 /* locale is ignored for Unicode */
2213 return GetStringTypeW( type
, src
, count
, chartype
);
2217 /******************************************************************************
2218 * GetStringTypeA (KERNEL32.@)
2220 * Get characteristics of the characters making up a string.
2223 * locale [I] Locale Id for the string
2224 * type [I] CT_CTYPE1 = classification, CT_CTYPE2 = directionality, CT_CTYPE3 = typographic info
2225 * src [I] String to analyse
2226 * count [I] Length of src in chars, or -1 if src is NUL terminated
2227 * chartype [O] Destination for the calculated characteristics
2230 * Success: TRUE. chartype is filled with the requested characteristics of each char
2232 * Failure: FALSE. Use GetLastError() to determine the cause.
2234 BOOL WINAPI
GetStringTypeA( LCID locale
, DWORD type
, LPCSTR src
, INT count
, LPWORD chartype
)
2241 if(count
== -1) count
= strlen(src
) + 1;
2243 if (!(cp
= get_lcid_codepage( locale
)))
2245 FIXME("For locale %04x using current ANSI code page\n", locale
);
2249 countW
= MultiByteToWideChar(cp
, 0, src
, count
, NULL
, 0);
2250 if((srcW
= HeapAlloc(GetProcessHeap(), 0, countW
* sizeof(WCHAR
))))
2252 MultiByteToWideChar(cp
, 0, src
, count
, srcW
, countW
);
2254 * NOTE: the target buffer has 1 word for each CHARACTER in the source
2255 * string, with multibyte characters there maybe be more bytes in count
2256 * than character space in the buffer!
2258 ret
= GetStringTypeW(type
, srcW
, countW
, chartype
);
2259 HeapFree(GetProcessHeap(), 0, srcW
);
2264 /******************************************************************************
2265 * GetStringTypeExA (KERNEL32.@)
2267 * Get characteristics of the characters making up a string.
2270 * locale [I] Locale Id for the string
2271 * type [I] CT_CTYPE1 = classification, CT_CTYPE2 = directionality, CT_CTYPE3 = typographic info
2272 * src [I] String to analyse
2273 * count [I] Length of src in chars, or -1 if src is NUL terminated
2274 * chartype [O] Destination for the calculated characteristics
2277 * Success: TRUE. chartype is filled with the requested characteristics of each char
2279 * Failure: FALSE. Use GetLastError() to determine the cause.
2281 BOOL WINAPI
GetStringTypeExA( LCID locale
, DWORD type
, LPCSTR src
, INT count
, LPWORD chartype
)
2283 return GetStringTypeA(locale
, type
, src
, count
, chartype
);
2287 /*************************************************************************
2288 * LCMapStringW (KERNEL32.@)
2292 INT WINAPI
LCMapStringW(LCID lcid
, DWORD flags
, LPCWSTR src
, INT srclen
,
2293 LPWSTR dst
, INT dstlen
)
2297 if (!src
|| !srclen
|| dstlen
< 0)
2299 SetLastError(ERROR_INVALID_PARAMETER
);
2303 /* mutually exclusive flags */
2304 if ((flags
& (LCMAP_LOWERCASE
| LCMAP_UPPERCASE
)) == (LCMAP_LOWERCASE
| LCMAP_UPPERCASE
) ||
2305 (flags
& (LCMAP_HIRAGANA
| LCMAP_KATAKANA
)) == (LCMAP_HIRAGANA
| LCMAP_KATAKANA
) ||
2306 (flags
& (LCMAP_HALFWIDTH
| LCMAP_FULLWIDTH
)) == (LCMAP_HALFWIDTH
| LCMAP_FULLWIDTH
) ||
2307 (flags
& (LCMAP_TRADITIONAL_CHINESE
| LCMAP_SIMPLIFIED_CHINESE
)) == (LCMAP_TRADITIONAL_CHINESE
| LCMAP_SIMPLIFIED_CHINESE
))
2309 SetLastError(ERROR_INVALID_FLAGS
);
2313 if (!dstlen
) dst
= NULL
;
2315 lcid
= ConvertDefaultLocale(lcid
);
2317 if (flags
& LCMAP_SORTKEY
)
2321 SetLastError(ERROR_INVALID_FLAGS
);
2325 if (srclen
< 0) srclen
= strlenW(src
);
2327 TRACE("(0x%04x,0x%08x,%s,%d,%p,%d)\n",
2328 lcid
, flags
, debugstr_wn(src
, srclen
), srclen
, dst
, dstlen
);
2330 return wine_get_sortkey(flags
, src
, srclen
, (char *)dst
, dstlen
);
2333 /* SORT_STRINGSORT must be used exclusively with LCMAP_SORTKEY */
2334 if (flags
& SORT_STRINGSORT
)
2336 SetLastError(ERROR_INVALID_FLAGS
);
2340 if (srclen
< 0) srclen
= strlenW(src
) + 1;
2342 TRACE("(0x%04x,0x%08x,%s,%d,%p,%d)\n",
2343 lcid
, flags
, debugstr_wn(src
, srclen
), srclen
, dst
, dstlen
);
2345 if (!dst
) /* return required string length */
2349 for (len
= 0; srclen
; src
++, srclen
--)
2352 /* tests show that win2k just ignores NORM_IGNORENONSPACE,
2353 * and skips white space and punctuation characters for
2354 * NORM_IGNORESYMBOLS.
2356 if ((flags
& NORM_IGNORESYMBOLS
) && (get_char_typeW(wch
) & (C1_PUNCT
| C1_SPACE
)))
2363 if (flags
& LCMAP_UPPERCASE
)
2365 for (dst_ptr
= dst
; srclen
&& dstlen
; src
++, srclen
--)
2368 if ((flags
& NORM_IGNORESYMBOLS
) && (get_char_typeW(wch
) & (C1_PUNCT
| C1_SPACE
)))
2370 *dst_ptr
++ = toupperW(wch
);
2374 else if (flags
& LCMAP_LOWERCASE
)
2376 for (dst_ptr
= dst
; srclen
&& dstlen
; src
++, srclen
--)
2379 if ((flags
& NORM_IGNORESYMBOLS
) && (get_char_typeW(wch
) & (C1_PUNCT
| C1_SPACE
)))
2381 *dst_ptr
++ = tolowerW(wch
);
2389 SetLastError(ERROR_INVALID_FLAGS
);
2392 for (dst_ptr
= dst
; srclen
&& dstlen
; src
++, srclen
--)
2395 if ((flags
& NORM_IGNORESYMBOLS
) && (get_char_typeW(wch
) & (C1_PUNCT
| C1_SPACE
)))
2404 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2408 return dst_ptr
- dst
;
2411 /*************************************************************************
2412 * LCMapStringA (KERNEL32.@)
2414 * Map characters in a locale sensitive string.
2417 * lcid [I] LCID for the conversion.
2418 * flags [I] Flags controlling the mapping (LCMAP_ constants from "winnls.h").
2419 * src [I] String to map
2420 * srclen [I] Length of src in chars, or -1 if src is NUL terminated
2421 * dst [O] Destination for mapped string
2422 * dstlen [I] Length of dst in characters
2425 * Success: The length of the mapped string in dst, including the NUL terminator.
2426 * Failure: 0. Use GetLastError() to determine the cause.
2428 INT WINAPI
LCMapStringA(LCID lcid
, DWORD flags
, LPCSTR src
, INT srclen
,
2429 LPSTR dst
, INT dstlen
)
2431 WCHAR
*bufW
= NtCurrentTeb()->StaticUnicodeBuffer
;
2433 INT ret
= 0, srclenW
, dstlenW
;
2434 UINT locale_cp
= CP_ACP
;
2436 if (!src
|| !srclen
|| dstlen
< 0)
2438 SetLastError(ERROR_INVALID_PARAMETER
);
2442 if (!(flags
& LOCALE_USE_CP_ACP
)) locale_cp
= get_lcid_codepage( lcid
);
2444 srclenW
= MultiByteToWideChar(locale_cp
, 0, src
, srclen
, bufW
, 260);
2449 srclenW
= MultiByteToWideChar(locale_cp
, 0, src
, srclen
, NULL
, 0);
2450 srcW
= HeapAlloc(GetProcessHeap(), 0, srclenW
* sizeof(WCHAR
));
2453 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2456 MultiByteToWideChar(locale_cp
, 0, src
, srclen
, srcW
, srclenW
);
2459 if (flags
& LCMAP_SORTKEY
)
2463 SetLastError(ERROR_INVALID_FLAGS
);
2464 goto map_string_exit
;
2466 ret
= wine_get_sortkey(flags
, srcW
, srclenW
, dst
, dstlen
);
2467 goto map_string_exit
;
2470 if (flags
& SORT_STRINGSORT
)
2472 SetLastError(ERROR_INVALID_FLAGS
);
2473 goto map_string_exit
;
2476 dstlenW
= LCMapStringW(lcid
, flags
, srcW
, srclenW
, NULL
, 0);
2478 goto map_string_exit
;
2480 dstW
= HeapAlloc(GetProcessHeap(), 0, dstlenW
* sizeof(WCHAR
));
2483 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2484 goto map_string_exit
;
2487 LCMapStringW(lcid
, flags
, srcW
, srclenW
, dstW
, dstlenW
);
2488 ret
= WideCharToMultiByte(locale_cp
, 0, dstW
, dstlenW
, dst
, dstlen
, NULL
, NULL
);
2489 HeapFree(GetProcessHeap(), 0, dstW
);
2492 if (srcW
!= bufW
) HeapFree(GetProcessHeap(), 0, srcW
);
2496 /*************************************************************************
2497 * FoldStringA (KERNEL32.@)
2499 * Map characters in a string.
2502 * dwFlags [I] Flags controlling chars to map (MAP_ constants from "winnls.h")
2503 * src [I] String to map
2504 * srclen [I] Length of src, or -1 if src is NUL terminated
2505 * dst [O] Destination for mapped string
2506 * dstlen [I] Length of dst, or 0 to find the required length for the mapped string
2509 * Success: The length of the string written to dst, including the terminating NUL. If
2510 * dstlen is 0, the value returned is the same, but nothing is written to dst,
2511 * and dst may be NULL.
2512 * Failure: 0. Use GetLastError() to determine the cause.
2514 INT WINAPI
FoldStringA(DWORD dwFlags
, LPCSTR src
, INT srclen
,
2515 LPSTR dst
, INT dstlen
)
2517 INT ret
= 0, srclenW
= 0;
2518 WCHAR
*srcW
= NULL
, *dstW
= NULL
;
2520 if (!src
|| !srclen
|| dstlen
< 0 || (dstlen
&& !dst
) || src
== dst
)
2522 SetLastError(ERROR_INVALID_PARAMETER
);
2526 srclenW
= MultiByteToWideChar(CP_ACP
, dwFlags
& MAP_COMPOSITE
? MB_COMPOSITE
: 0,
2527 src
, srclen
, NULL
, 0);
2528 srcW
= HeapAlloc(GetProcessHeap(), 0, srclenW
* sizeof(WCHAR
));
2532 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2533 goto FoldStringA_exit
;
2536 MultiByteToWideChar(CP_ACP
, dwFlags
& MAP_COMPOSITE
? MB_COMPOSITE
: 0,
2537 src
, srclen
, srcW
, srclenW
);
2539 dwFlags
= (dwFlags
& ~MAP_PRECOMPOSED
) | MAP_FOLDCZONE
;
2541 ret
= FoldStringW(dwFlags
, srcW
, srclenW
, NULL
, 0);
2544 dstW
= HeapAlloc(GetProcessHeap(), 0, ret
* sizeof(WCHAR
));
2548 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2549 goto FoldStringA_exit
;
2552 ret
= FoldStringW(dwFlags
, srcW
, srclenW
, dstW
, ret
);
2553 if (!WideCharToMultiByte(CP_ACP
, 0, dstW
, ret
, dst
, dstlen
, NULL
, NULL
))
2556 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2560 HeapFree(GetProcessHeap(), 0, dstW
);
2563 HeapFree(GetProcessHeap(), 0, srcW
);
2567 /*************************************************************************
2568 * FoldStringW (KERNEL32.@)
2572 INT WINAPI
FoldStringW(DWORD dwFlags
, LPCWSTR src
, INT srclen
,
2573 LPWSTR dst
, INT dstlen
)
2577 switch (dwFlags
& (MAP_COMPOSITE
|MAP_PRECOMPOSED
|MAP_EXPAND_LIGATURES
))
2582 /* Fall through for dwFlags == 0 */
2583 case MAP_PRECOMPOSED
|MAP_COMPOSITE
:
2584 case MAP_PRECOMPOSED
|MAP_EXPAND_LIGATURES
:
2585 case MAP_COMPOSITE
|MAP_EXPAND_LIGATURES
:
2586 SetLastError(ERROR_INVALID_FLAGS
);
2590 if (!src
|| !srclen
|| dstlen
< 0 || (dstlen
&& !dst
) || src
== dst
)
2592 SetLastError(ERROR_INVALID_PARAMETER
);
2596 ret
= wine_fold_string(dwFlags
, src
, srclen
, dst
, dstlen
);
2598 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2602 /******************************************************************************
2603 * CompareStringW (KERNEL32.@)
2605 * See CompareStringA.
2607 INT WINAPI
CompareStringW(LCID lcid
, DWORD style
,
2608 LPCWSTR str1
, INT len1
, LPCWSTR str2
, INT len2
)
2614 SetLastError(ERROR_INVALID_PARAMETER
);
2618 if( style
& ~(NORM_IGNORECASE
|NORM_IGNORENONSPACE
|NORM_IGNORESYMBOLS
|
2619 SORT_STRINGSORT
|NORM_IGNOREKANATYPE
|NORM_IGNOREWIDTH
|LOCALE_USE_CP_ACP
|0x10000000) )
2621 SetLastError(ERROR_INVALID_FLAGS
);
2625 /* this style is related to diacritics in Arabic, Japanese, and Hebrew */
2626 if (style
& 0x10000000)
2627 WARN("Ignoring unknown style 0x10000000\n");
2629 if (len1
< 0) len1
= strlenW(str1
);
2630 if (len2
< 0) len2
= strlenW(str2
);
2632 ret
= wine_compare_string(style
, str1
, len1
, str2
, len2
);
2634 if (ret
) /* need to translate result */
2635 return (ret
< 0) ? CSTR_LESS_THAN
: CSTR_GREATER_THAN
;
2639 /******************************************************************************
2640 * CompareStringA (KERNEL32.@)
2642 * Compare two locale sensitive strings.
2645 * lcid [I] LCID for the comparison
2646 * style [I] Flags for the comparison (NORM_ constants from "winnls.h").
2647 * str1 [I] First string to compare
2648 * len1 [I] Length of str1, or -1 if str1 is NUL terminated
2649 * str2 [I] Second string to compare
2650 * len2 [I] Length of str2, or -1 if str2 is NUL terminated
2653 * Success: CSTR_LESS_THAN, CSTR_EQUAL or CSTR_GREATER_THAN depending on whether
2654 * str2 is less than, equal to or greater than str1 respectively.
2655 * Failure: FALSE. Use GetLastError() to determine the cause.
2657 INT WINAPI
CompareStringA(LCID lcid
, DWORD style
,
2658 LPCSTR str1
, INT len1
, LPCSTR str2
, INT len2
)
2660 WCHAR
*buf1W
= NtCurrentTeb()->StaticUnicodeBuffer
;
2661 WCHAR
*buf2W
= buf1W
+ 130;
2662 LPWSTR str1W
, str2W
;
2663 INT len1W
, len2W
, ret
;
2664 UINT locale_cp
= CP_ACP
;
2668 SetLastError(ERROR_INVALID_PARAMETER
);
2671 if (len1
< 0) len1
= strlen(str1
);
2672 if (len2
< 0) len2
= strlen(str2
);
2674 if (!(style
& LOCALE_USE_CP_ACP
)) locale_cp
= get_lcid_codepage( lcid
);
2676 len1W
= MultiByteToWideChar(locale_cp
, 0, str1
, len1
, buf1W
, 130);
2681 len1W
= MultiByteToWideChar(locale_cp
, 0, str1
, len1
, NULL
, 0);
2682 str1W
= HeapAlloc(GetProcessHeap(), 0, len1W
* sizeof(WCHAR
));
2685 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2688 MultiByteToWideChar(locale_cp
, 0, str1
, len1
, str1W
, len1W
);
2690 len2W
= MultiByteToWideChar(locale_cp
, 0, str2
, len2
, buf2W
, 130);
2695 len2W
= MultiByteToWideChar(locale_cp
, 0, str2
, len2
, NULL
, 0);
2696 str2W
= HeapAlloc(GetProcessHeap(), 0, len2W
* sizeof(WCHAR
));
2699 if (str1W
!= buf1W
) HeapFree(GetProcessHeap(), 0, str1W
);
2700 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2703 MultiByteToWideChar(locale_cp
, 0, str2
, len2
, str2W
, len2W
);
2706 ret
= CompareStringW(lcid
, style
, str1W
, len1W
, str2W
, len2W
);
2708 if (str1W
!= buf1W
) HeapFree(GetProcessHeap(), 0, str1W
);
2709 if (str2W
!= buf2W
) HeapFree(GetProcessHeap(), 0, str2W
);
2713 /*************************************************************************
2714 * lstrcmp (KERNEL32.@)
2715 * lstrcmpA (KERNEL32.@)
2717 * Compare two strings using the current thread locale.
2720 * str1 [I] First string to compare
2721 * str2 [I] Second string to compare
2724 * Success: A number less than, equal to or greater than 0 depending on whether
2725 * str2 is less than, equal to or greater than str1 respectively.
2726 * Failure: FALSE. Use GetLastError() to determine the cause.
2728 int WINAPI
lstrcmpA(LPCSTR str1
, LPCSTR str2
)
2732 if ((str1
== NULL
) && (str2
== NULL
)) return 0;
2733 if (str1
== NULL
) return -1;
2734 if (str2
== NULL
) return 1;
2736 ret
= CompareStringA(GetThreadLocale(), LOCALE_USE_CP_ACP
, str1
, -1, str2
, -1);
2742 /*************************************************************************
2743 * lstrcmpi (KERNEL32.@)
2744 * lstrcmpiA (KERNEL32.@)
2746 * Compare two strings using the current thread locale, ignoring case.
2749 * str1 [I] First string to compare
2750 * str2 [I] Second string to compare
2753 * Success: A number less than, equal to or greater than 0 depending on whether
2754 * str2 is less than, equal to or greater than str1 respectively.
2755 * Failure: FALSE. Use GetLastError() to determine the cause.
2757 int WINAPI
lstrcmpiA(LPCSTR str1
, LPCSTR str2
)
2761 if ((str1
== NULL
) && (str2
== NULL
)) return 0;
2762 if (str1
== NULL
) return -1;
2763 if (str2
== NULL
) return 1;
2765 ret
= CompareStringA(GetThreadLocale(), NORM_IGNORECASE
|LOCALE_USE_CP_ACP
, str1
, -1, str2
, -1);
2771 /*************************************************************************
2772 * lstrcmpW (KERNEL32.@)
2776 int WINAPI
lstrcmpW(LPCWSTR str1
, LPCWSTR str2
)
2780 if ((str1
== NULL
) && (str2
== NULL
)) return 0;
2781 if (str1
== NULL
) return -1;
2782 if (str2
== NULL
) return 1;
2784 ret
= CompareStringW(GetThreadLocale(), 0, str1
, -1, str2
, -1);
2790 /*************************************************************************
2791 * lstrcmpiW (KERNEL32.@)
2795 int WINAPI
lstrcmpiW(LPCWSTR str1
, LPCWSTR str2
)
2799 if ((str1
== NULL
) && (str2
== NULL
)) return 0;
2800 if (str1
== NULL
) return -1;
2801 if (str2
== NULL
) return 1;
2803 ret
= CompareStringW(GetThreadLocale(), NORM_IGNORECASE
, str1
, -1, str2
, -1);
2809 /******************************************************************************
2812 void LOCALE_Init(void)
2814 extern void __wine_init_codepages( const union cptable
*ansi_cp
, const union cptable
*oem_cp
,
2815 const union cptable
*unix_cp
);
2817 UINT ansi_cp
= 1252, oem_cp
= 437, mac_cp
= 10000, unix_cp
;
2820 /* MacOS doesn't set the locale environment variables so we have to do it ourselves */
2821 CFArrayRef preferred_locales
, all_locales
;
2822 CFStringRef user_language_string_ref
= NULL
;
2823 char user_locale
[50];
2825 CFLocaleRef user_locale_ref
= CFLocaleCopyCurrent();
2826 CFStringRef user_locale_string_ref
= CFLocaleGetIdentifier( user_locale_ref
);
2828 CFStringGetCString( user_locale_string_ref
, user_locale
, sizeof(user_locale
), kCFStringEncodingUTF8
);
2829 CFRelease( user_locale_ref
);
2830 if (!strchr( user_locale
, '.' )) strcat( user_locale
, ".UTF-8" );
2831 unix_cp
= CP_UTF8
; /* default to utf-8 even if we don't get a valid locale */
2832 setenv( "LANG", user_locale
, 0 );
2833 TRACE( "setting locale to '%s'\n", user_locale
);
2835 /* We still want to set the retrieve the preferred language as chosen in
2836 System Preferences.app, because it can differ from CFLocaleCopyCurrent().
2838 all_locales
= CFLocaleCopyAvailableLocaleIdentifiers();
2839 preferred_locales
= CFBundleCopyLocalizationsForPreferences( all_locales
, NULL
);
2840 if (preferred_locales
&& CFArrayGetCount( preferred_locales
))
2841 user_language_string_ref
= CFArrayGetValueAtIndex( preferred_locales
, 0 );
2842 CFRelease( all_locales
);
2843 #endif /* __APPLE__ */
2845 setlocale( LC_ALL
, "" );
2847 unix_cp
= setup_unix_locales();
2848 if (!lcid_LC_MESSAGES
) lcid_LC_MESSAGES
= lcid_LC_CTYPE
;
2851 /* Override lcid_LC_MESSAGES with user_language if LC_MESSAGES is set to default */
2852 if (lcid_LC_MESSAGES
== lcid_LC_CTYPE
&& user_language_string_ref
)
2854 struct locale_name locale_name
;
2856 CFStringGetCString( user_language_string_ref
, user_locale
, sizeof(user_locale
), kCFStringEncodingUTF8
);
2857 strcpynAtoW( buffer
, user_locale
, sizeof(buffer
)/sizeof(WCHAR
) );
2858 parse_locale_name( buffer
, &locale_name
);
2859 lcid_LC_MESSAGES
= locale_name
.lcid
;
2860 TRACE( "setting lcid_LC_MESSAGES to '%s'\n", user_locale
);
2862 if (preferred_locales
)
2863 CFRelease( preferred_locales
);
2866 NtSetDefaultUILanguage( LANGIDFROMLCID(lcid_LC_MESSAGES
) );
2867 NtSetDefaultLocale( TRUE
, lcid_LC_MESSAGES
);
2868 NtSetDefaultLocale( FALSE
, lcid_LC_CTYPE
);
2870 ansi_cp
= get_lcid_codepage( LOCALE_USER_DEFAULT
);
2871 GetLocaleInfoW( LOCALE_USER_DEFAULT
, LOCALE_IDEFAULTMACCODEPAGE
| LOCALE_RETURN_NUMBER
,
2872 (LPWSTR
)&mac_cp
, sizeof(mac_cp
)/sizeof(WCHAR
) );
2873 GetLocaleInfoW( LOCALE_USER_DEFAULT
, LOCALE_IDEFAULTCODEPAGE
| LOCALE_RETURN_NUMBER
,
2874 (LPWSTR
)&oem_cp
, sizeof(oem_cp
)/sizeof(WCHAR
) );
2876 GetLocaleInfoW( LOCALE_USER_DEFAULT
, LOCALE_IDEFAULTUNIXCODEPAGE
| LOCALE_RETURN_NUMBER
,
2877 (LPWSTR
)&unix_cp
, sizeof(unix_cp
)/sizeof(WCHAR
) );
2879 if (!(ansi_cptable
= wine_cp_get_table( ansi_cp
)))
2880 ansi_cptable
= wine_cp_get_table( 1252 );
2881 if (!(oem_cptable
= wine_cp_get_table( oem_cp
)))
2882 oem_cptable
= wine_cp_get_table( 437 );
2883 if (!(mac_cptable
= wine_cp_get_table( mac_cp
)))
2884 mac_cptable
= wine_cp_get_table( 10000 );
2885 if (unix_cp
!= CP_UTF8
)
2887 if (!(unix_cptable
= wine_cp_get_table( unix_cp
)))
2888 unix_cptable
= wine_cp_get_table( 28591 );
2891 __wine_init_codepages( ansi_cptable
, oem_cptable
, unix_cptable
);
2893 TRACE( "ansi=%03d oem=%03d mac=%03d unix=%03d\n",
2894 ansi_cptable
->info
.codepage
, oem_cptable
->info
.codepage
,
2895 mac_cptable
->info
.codepage
, unix_cp
);
2897 setlocale(LC_NUMERIC
, "C"); /* FIXME: oleaut32 depends on this */
2900 static HANDLE
NLS_RegOpenKey(HANDLE hRootKey
, LPCWSTR szKeyName
)
2902 UNICODE_STRING keyName
;
2903 OBJECT_ATTRIBUTES attr
;
2906 RtlInitUnicodeString( &keyName
, szKeyName
);
2907 InitializeObjectAttributes(&attr
, &keyName
, 0, hRootKey
, NULL
);
2909 if (NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
) != STATUS_SUCCESS
)
2915 static HANDLE
NLS_RegOpenSubKey(HANDLE hRootKey
, LPCWSTR szKeyName
)
2917 HANDLE hKey
= NLS_RegOpenKey(hRootKey
, szKeyName
);
2920 NtClose( hRootKey
);
2925 static BOOL
NLS_RegEnumSubKey(HANDLE hKey
, UINT ulIndex
, LPWSTR szKeyName
,
2929 KEY_BASIC_INFORMATION
*info
= (KEY_BASIC_INFORMATION
*)buffer
;
2932 if (NtEnumerateKey( hKey
, ulIndex
, KeyBasicInformation
, buffer
,
2933 sizeof(buffer
), &dwLen
) != STATUS_SUCCESS
||
2934 info
->NameLength
> keyNameSize
)
2939 TRACE("info->Name %s info->NameLength %d\n", debugstr_w(info
->Name
), info
->NameLength
);
2941 memcpy( szKeyName
, info
->Name
, info
->NameLength
);
2942 szKeyName
[info
->NameLength
/ sizeof(WCHAR
)] = '\0';
2944 TRACE("returning %s\n", debugstr_w(szKeyName
));
2948 static BOOL
NLS_RegEnumValue(HANDLE hKey
, UINT ulIndex
,
2949 LPWSTR szValueName
, ULONG valueNameSize
,
2950 LPWSTR szValueData
, ULONG valueDataSize
)
2953 KEY_VALUE_FULL_INFORMATION
*info
= (KEY_VALUE_FULL_INFORMATION
*)buffer
;
2956 if (NtEnumerateValueKey( hKey
, ulIndex
, KeyValueFullInformation
,
2957 buffer
, sizeof(buffer
), &dwLen
) != STATUS_SUCCESS
||
2958 info
->NameLength
> valueNameSize
||
2959 info
->DataLength
> valueDataSize
)
2964 TRACE("info->Name %s info->DataLength %d\n", debugstr_w(info
->Name
), info
->DataLength
);
2966 memcpy( szValueName
, info
->Name
, info
->NameLength
);
2967 szValueName
[info
->NameLength
/ sizeof(WCHAR
)] = '\0';
2968 memcpy( szValueData
, buffer
+ info
->DataOffset
, info
->DataLength
);
2969 szValueData
[info
->DataLength
/ sizeof(WCHAR
)] = '\0';
2971 TRACE("returning %s %s\n", debugstr_w(szValueName
), debugstr_w(szValueData
));
2975 static BOOL
NLS_RegGetDword(HANDLE hKey
, LPCWSTR szValueName
, DWORD
*lpVal
)
2978 const KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)buffer
;
2979 DWORD dwSize
= sizeof(buffer
);
2980 UNICODE_STRING valueName
;
2982 RtlInitUnicodeString( &valueName
, szValueName
);
2984 TRACE("%p, %s\n", hKey
, debugstr_w(szValueName
));
2985 if (NtQueryValueKey( hKey
, &valueName
, KeyValuePartialInformation
,
2986 buffer
, dwSize
, &dwSize
) == STATUS_SUCCESS
&&
2987 info
->DataLength
== sizeof(DWORD
))
2989 memcpy(lpVal
, info
->Data
, sizeof(DWORD
));
2996 static BOOL
NLS_GetLanguageGroupName(LGRPID lgrpid
, LPWSTR szName
, ULONG nameSize
)
2999 LPCWSTR szResourceName
= MAKEINTRESOURCEW(((lgrpid
+ 0x2000) >> 4) + 1);
3003 /* FIXME: Is it correct to use the system default langid? */
3004 langId
= GetSystemDefaultLangID();
3006 if (SUBLANGID(langId
) == SUBLANG_NEUTRAL
)
3007 langId
= MAKELANGID( PRIMARYLANGID(langId
), SUBLANG_DEFAULT
);
3009 hResource
= FindResourceExW( kernel32_handle
, (LPWSTR
)RT_STRING
, szResourceName
, langId
);
3013 HGLOBAL hResDir
= LoadResource( kernel32_handle
, hResource
);
3017 ULONG iResourceIndex
= lgrpid
& 0xf;
3018 LPCWSTR lpResEntry
= LockResource( hResDir
);
3021 for (i
= 0; i
< iResourceIndex
; i
++)
3022 lpResEntry
+= *lpResEntry
+ 1;
3024 if (*lpResEntry
< nameSize
)
3026 memcpy( szName
, lpResEntry
+ 1, *lpResEntry
* sizeof(WCHAR
) );
3027 szName
[*lpResEntry
] = '\0';
3032 FreeResource( hResource
);
3037 /* Registry keys for NLS related information */
3038 static const WCHAR szLangGroupsKeyName
[] = {
3039 'L','a','n','g','u','a','g','e',' ','G','r','o','u','p','s','\0'
3042 static const WCHAR szCountryListName
[] = {
3043 'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\',
3044 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
3045 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3046 'T','e','l','e','p','h','o','n','y','\\',
3047 'C','o','u','n','t','r','y',' ','L','i','s','t','\0'
3051 /* Callback function ptrs for EnumSystemLanguageGroupsA/W */
3054 LANGUAGEGROUP_ENUMPROCA procA
;
3055 LANGUAGEGROUP_ENUMPROCW procW
;
3058 } ENUMLANGUAGEGROUP_CALLBACKS
;
3060 /* Internal implementation of EnumSystemLanguageGroupsA/W */
3061 static BOOL
NLS_EnumSystemLanguageGroups(ENUMLANGUAGEGROUP_CALLBACKS
*lpProcs
)
3063 WCHAR szNumber
[10], szValue
[4];
3065 BOOL bContinue
= TRUE
;
3070 SetLastError(ERROR_INVALID_PARAMETER
);
3074 switch (lpProcs
->dwFlags
)
3077 /* Default to LGRPID_INSTALLED */
3078 lpProcs
->dwFlags
= LGRPID_INSTALLED
;
3079 /* Fall through... */
3080 case LGRPID_INSTALLED
:
3081 case LGRPID_SUPPORTED
:
3084 SetLastError(ERROR_INVALID_FLAGS
);
3088 hKey
= NLS_RegOpenSubKey( NLS_RegOpenKey( 0, szNlsKeyName
), szLangGroupsKeyName
);
3091 FIXME("NLS registry key not found. Please apply the default registry file 'wine.inf'\n");
3095 if (NLS_RegEnumValue( hKey
, ulIndex
, szNumber
, sizeof(szNumber
),
3096 szValue
, sizeof(szValue
) ))
3098 BOOL bInstalled
= szValue
[0] == '1' ? TRUE
: FALSE
;
3099 LGRPID lgrpid
= strtoulW( szNumber
, NULL
, 16 );
3101 TRACE("grpid %s (%sinstalled)\n", debugstr_w(szNumber
),
3102 bInstalled
? "" : "not ");
3104 if (lpProcs
->dwFlags
== LGRPID_SUPPORTED
|| bInstalled
)
3106 WCHAR szGrpName
[48];
3108 if (!NLS_GetLanguageGroupName( lgrpid
, szGrpName
, sizeof(szGrpName
) / sizeof(WCHAR
) ))
3109 szGrpName
[0] = '\0';
3112 bContinue
= lpProcs
->procW( lgrpid
, szNumber
, szGrpName
, lpProcs
->dwFlags
,
3116 char szNumberA
[sizeof(szNumber
)/sizeof(WCHAR
)];
3117 char szGrpNameA
[48];
3119 /* FIXME: MSDN doesn't say which code page the W->A translation uses,
3120 * or whether the language names are ever localised. Assume CP_ACP.
3123 WideCharToMultiByte(CP_ACP
, 0, szNumber
, -1, szNumberA
, sizeof(szNumberA
), 0, 0);
3124 WideCharToMultiByte(CP_ACP
, 0, szGrpName
, -1, szGrpNameA
, sizeof(szGrpNameA
), 0, 0);
3126 bContinue
= lpProcs
->procA( lgrpid
, szNumberA
, szGrpNameA
, lpProcs
->dwFlags
,
3146 /******************************************************************************
3147 * EnumSystemLanguageGroupsA (KERNEL32.@)
3149 * Call a users function for each language group available on the system.
3152 * pLangGrpEnumProc [I] Callback function to call for each language group
3153 * dwFlags [I] LGRPID_SUPPORTED=All Supported, LGRPID_INSTALLED=Installed only
3154 * lParam [I] User parameter to pass to pLangGrpEnumProc
3158 * Failure: FALSE. Use GetLastError() to determine the cause.
3160 BOOL WINAPI
EnumSystemLanguageGroupsA(LANGUAGEGROUP_ENUMPROCA pLangGrpEnumProc
,
3161 DWORD dwFlags
, LONG_PTR lParam
)
3163 ENUMLANGUAGEGROUP_CALLBACKS procs
;
3165 TRACE("(%p,0x%08X,0x%08lX)\n", pLangGrpEnumProc
, dwFlags
, lParam
);
3167 procs
.procA
= pLangGrpEnumProc
;
3169 procs
.dwFlags
= dwFlags
;
3170 procs
.lParam
= lParam
;
3172 return NLS_EnumSystemLanguageGroups( pLangGrpEnumProc
? &procs
: NULL
);
3175 /******************************************************************************
3176 * EnumSystemLanguageGroupsW (KERNEL32.@)
3178 * See EnumSystemLanguageGroupsA.
3180 BOOL WINAPI
EnumSystemLanguageGroupsW(LANGUAGEGROUP_ENUMPROCW pLangGrpEnumProc
,
3181 DWORD dwFlags
, LONG_PTR lParam
)
3183 ENUMLANGUAGEGROUP_CALLBACKS procs
;
3185 TRACE("(%p,0x%08X,0x%08lX)\n", pLangGrpEnumProc
, dwFlags
, lParam
);
3188 procs
.procW
= pLangGrpEnumProc
;
3189 procs
.dwFlags
= dwFlags
;
3190 procs
.lParam
= lParam
;
3192 return NLS_EnumSystemLanguageGroups( pLangGrpEnumProc
? &procs
: NULL
);
3195 /******************************************************************************
3196 * IsValidLanguageGroup (KERNEL32.@)
3198 * Determine if a language group is supported and/or installed.
3201 * lgrpid [I] Language Group Id (LGRPID_ values from "winnls.h")
3202 * dwFlags [I] LGRPID_SUPPORTED=Supported, LGRPID_INSTALLED=Installed
3205 * TRUE, if lgrpid is supported and/or installed, according to dwFlags.
3208 BOOL WINAPI
IsValidLanguageGroup(LGRPID lgrpid
, DWORD dwFlags
)
3210 static const WCHAR szFormat
[] = { '%','x','\0' };
3211 WCHAR szValueName
[16], szValue
[2];
3212 BOOL bSupported
= FALSE
, bInstalled
= FALSE
;
3218 case LGRPID_INSTALLED
:
3219 case LGRPID_SUPPORTED
:
3221 hKey
= NLS_RegOpenSubKey( NLS_RegOpenKey( 0, szNlsKeyName
), szLangGroupsKeyName
);
3223 sprintfW( szValueName
, szFormat
, lgrpid
);
3225 if (NLS_RegGetDword( hKey
, szValueName
, (LPDWORD
)&szValue
))
3229 if (szValue
[0] == '1')
3239 if ((dwFlags
== LGRPID_SUPPORTED
&& bSupported
) ||
3240 (dwFlags
== LGRPID_INSTALLED
&& bInstalled
))
3246 /* Callback function ptrs for EnumLanguageGrouplocalesA/W */
3249 LANGGROUPLOCALE_ENUMPROCA procA
;
3250 LANGGROUPLOCALE_ENUMPROCW procW
;
3254 } ENUMLANGUAGEGROUPLOCALE_CALLBACKS
;
3256 /* Internal implementation of EnumLanguageGrouplocalesA/W */
3257 static BOOL
NLS_EnumLanguageGroupLocales(ENUMLANGUAGEGROUPLOCALE_CALLBACKS
*lpProcs
)
3259 static const WCHAR szLocaleKeyName
[] = {
3260 'L','o','c','a','l','e','\0'
3262 static const WCHAR szAlternateSortsKeyName
[] = {
3263 'A','l','t','e','r','n','a','t','e',' ','S','o','r','t','s','\0'
3265 WCHAR szNumber
[10], szValue
[4];
3267 BOOL bContinue
= TRUE
, bAlternate
= FALSE
;
3269 ULONG ulIndex
= 1; /* Ignore default entry of 1st key */
3271 if (!lpProcs
|| !lpProcs
->lgrpid
|| lpProcs
->lgrpid
> LGRPID_ARMENIAN
)
3273 SetLastError(ERROR_INVALID_PARAMETER
);
3277 if (lpProcs
->dwFlags
)
3279 SetLastError(ERROR_INVALID_FLAGS
);
3283 hKey
= NLS_RegOpenSubKey( NLS_RegOpenKey( 0, szNlsKeyName
), szLocaleKeyName
);
3286 WARN("NLS registry key not found. Please apply the default registry file 'wine.inf'\n");
3290 if (NLS_RegEnumValue( hKey
, ulIndex
, szNumber
, sizeof(szNumber
),
3291 szValue
, sizeof(szValue
) ))
3293 lgrpid
= strtoulW( szValue
, NULL
, 16 );
3295 TRACE("lcid %s, grpid %d (%smatched)\n", debugstr_w(szNumber
),
3296 lgrpid
, lgrpid
== lpProcs
->lgrpid
? "" : "not ");
3298 if (lgrpid
== lpProcs
->lgrpid
)
3302 lcid
= strtoulW( szNumber
, NULL
, 16 );
3304 /* FIXME: native returns extra text for a few (17/150) locales, e.g:
3305 * '00000437 ;Georgian'
3306 * At present we only pass the LCID string.
3310 bContinue
= lpProcs
->procW( lgrpid
, lcid
, szNumber
, lpProcs
->lParam
);
3313 char szNumberA
[sizeof(szNumber
)/sizeof(WCHAR
)];
3315 WideCharToMultiByte(CP_ACP
, 0, szNumber
, -1, szNumberA
, sizeof(szNumberA
), 0, 0);
3317 bContinue
= lpProcs
->procA( lgrpid
, lcid
, szNumberA
, lpProcs
->lParam
);
3325 /* Finished enumerating this key */
3328 /* Enumerate alternate sorts also */
3329 hKey
= NLS_RegOpenKey( hKey
, szAlternateSortsKeyName
);
3334 bContinue
= FALSE
; /* Finished both keys */
3347 /******************************************************************************
3348 * EnumLanguageGroupLocalesA (KERNEL32.@)
3350 * Call a users function for every locale in a language group available on the system.
3353 * pLangGrpLcEnumProc [I] Callback function to call for each locale
3354 * lgrpid [I] Language group (LGRPID_ values from "winnls.h")
3355 * dwFlags [I] Reserved, set to 0
3356 * lParam [I] User parameter to pass to pLangGrpLcEnumProc
3360 * Failure: FALSE. Use GetLastError() to determine the cause.
3362 BOOL WINAPI
EnumLanguageGroupLocalesA(LANGGROUPLOCALE_ENUMPROCA pLangGrpLcEnumProc
,
3363 LGRPID lgrpid
, DWORD dwFlags
, LONG_PTR lParam
)
3365 ENUMLANGUAGEGROUPLOCALE_CALLBACKS callbacks
;
3367 TRACE("(%p,0x%08X,0x%08X,0x%08lX)\n", pLangGrpLcEnumProc
, lgrpid
, dwFlags
, lParam
);
3369 callbacks
.procA
= pLangGrpLcEnumProc
;
3370 callbacks
.procW
= NULL
;
3371 callbacks
.dwFlags
= dwFlags
;
3372 callbacks
.lgrpid
= lgrpid
;
3373 callbacks
.lParam
= lParam
;
3375 return NLS_EnumLanguageGroupLocales( pLangGrpLcEnumProc
? &callbacks
: NULL
);
3378 /******************************************************************************
3379 * EnumLanguageGroupLocalesW (KERNEL32.@)
3381 * See EnumLanguageGroupLocalesA.
3383 BOOL WINAPI
EnumLanguageGroupLocalesW(LANGGROUPLOCALE_ENUMPROCW pLangGrpLcEnumProc
,
3384 LGRPID lgrpid
, DWORD dwFlags
, LONG_PTR lParam
)
3386 ENUMLANGUAGEGROUPLOCALE_CALLBACKS callbacks
;
3388 TRACE("(%p,0x%08X,0x%08X,0x%08lX)\n", pLangGrpLcEnumProc
, lgrpid
, dwFlags
, lParam
);
3390 callbacks
.procA
= NULL
;
3391 callbacks
.procW
= pLangGrpLcEnumProc
;
3392 callbacks
.dwFlags
= dwFlags
;
3393 callbacks
.lgrpid
= lgrpid
;
3394 callbacks
.lParam
= lParam
;
3396 return NLS_EnumLanguageGroupLocales( pLangGrpLcEnumProc
? &callbacks
: NULL
);
3399 /******************************************************************************
3400 * EnumSystemGeoID (KERNEL32.@)
3402 * Call a users function for every location available on the system.
3405 * geoclass [I] Type of information desired (SYSGEOTYPE enum from "winnls.h")
3406 * reserved [I] Reserved, set to 0
3407 * pGeoEnumProc [I] Callback function to call for each location
3411 * Failure: FALSE. Use GetLastError() to determine the cause.
3413 BOOL WINAPI
EnumSystemGeoID(GEOCLASS geoclass
, GEOID reserved
, GEO_ENUMPROC pGeoEnumProc
)
3415 static const WCHAR szCountryCodeValueName
[] = {
3416 'C','o','u','n','t','r','y','C','o','d','e','\0'
3422 TRACE("(0x%08X,0x%08X,%p)\n", geoclass
, reserved
, pGeoEnumProc
);
3424 if (geoclass
!= GEOCLASS_NATION
|| reserved
|| !pGeoEnumProc
)
3426 SetLastError(ERROR_INVALID_PARAMETER
);
3430 hKey
= NLS_RegOpenKey( 0, szCountryListName
);
3432 while (NLS_RegEnumSubKey( hKey
, ulIndex
, szNumber
, sizeof(szNumber
) ))
3434 BOOL bContinue
= TRUE
;
3436 HANDLE hSubKey
= NLS_RegOpenKey( hKey
, szNumber
);
3440 if (NLS_RegGetDword( hSubKey
, szCountryCodeValueName
, &dwGeoId
))
3442 TRACE("Got geoid %d\n", dwGeoId
);
3444 if (!pGeoEnumProc( dwGeoId
))
3463 /******************************************************************************
3464 * InvalidateNLSCache (KERNEL32.@)
3466 * Invalidate the cache of NLS values.
3475 BOOL WINAPI
InvalidateNLSCache(void)
3481 /******************************************************************************
3482 * GetUserGeoID (KERNEL32.@)
3484 GEOID WINAPI
GetUserGeoID( GEOCLASS GeoClass
)
3486 FIXME("%d\n",GeoClass
);
3487 return GEOID_NOT_AVAILABLE
;
3490 /******************************************************************************
3491 * SetUserGeoID (KERNEL32.@)
3493 BOOL WINAPI
SetUserGeoID( GEOID GeoID
)
3495 FIXME("%d\n",GeoID
);
3503 UILANGUAGE_ENUMPROCA procA
;
3504 UILANGUAGE_ENUMPROCW procW
;
3508 } ENUM_UILANG_CALLBACK
;
3510 static BOOL CALLBACK
enum_uilang_proc_a( HMODULE hModule
, LPCSTR type
,
3511 LPCSTR name
, WORD LangID
, LONG_PTR lParam
)
3513 ENUM_UILANG_CALLBACK
*enum_uilang
= (ENUM_UILANG_CALLBACK
*)lParam
;
3516 sprintf(buf
, "%08x", (UINT
)LangID
);
3517 return enum_uilang
->u
.procA( buf
, enum_uilang
->param
);
3520 static BOOL CALLBACK
enum_uilang_proc_w( HMODULE hModule
, LPCWSTR type
,
3521 LPCWSTR name
, WORD LangID
, LONG_PTR lParam
)
3523 static const WCHAR formatW
[] = {'%','0','8','x',0};
3524 ENUM_UILANG_CALLBACK
*enum_uilang
= (ENUM_UILANG_CALLBACK
*)lParam
;
3527 sprintfW( buf
, formatW
, (UINT
)LangID
);
3528 return enum_uilang
->u
.procW( buf
, enum_uilang
->param
);
3531 /******************************************************************************
3532 * EnumUILanguagesA (KERNEL32.@)
3534 BOOL WINAPI
EnumUILanguagesA(UILANGUAGE_ENUMPROCA pUILangEnumProc
, DWORD dwFlags
, LONG_PTR lParam
)
3536 ENUM_UILANG_CALLBACK enum_uilang
;
3538 TRACE("%p, %x, %lx\n", pUILangEnumProc
, dwFlags
, lParam
);
3540 if(!pUILangEnumProc
) {
3541 SetLastError(ERROR_INVALID_PARAMETER
);
3545 SetLastError(ERROR_INVALID_FLAGS
);
3549 enum_uilang
.u
.procA
= pUILangEnumProc
;
3550 enum_uilang
.flags
= dwFlags
;
3551 enum_uilang
.param
= lParam
;
3553 EnumResourceLanguagesA( kernel32_handle
, (LPCSTR
)RT_STRING
,
3554 (LPCSTR
)LOCALE_ILANGUAGE
, enum_uilang_proc_a
,
3555 (LONG_PTR
)&enum_uilang
);
3559 /******************************************************************************
3560 * EnumUILanguagesW (KERNEL32.@)
3562 BOOL WINAPI
EnumUILanguagesW(UILANGUAGE_ENUMPROCW pUILangEnumProc
, DWORD dwFlags
, LONG_PTR lParam
)
3564 ENUM_UILANG_CALLBACK enum_uilang
;
3566 TRACE("%p, %x, %lx\n", pUILangEnumProc
, dwFlags
, lParam
);
3569 if(!pUILangEnumProc
) {
3570 SetLastError(ERROR_INVALID_PARAMETER
);
3574 SetLastError(ERROR_INVALID_FLAGS
);
3578 enum_uilang
.u
.procW
= pUILangEnumProc
;
3579 enum_uilang
.flags
= dwFlags
;
3580 enum_uilang
.param
= lParam
;
3582 EnumResourceLanguagesW( kernel32_handle
, (LPCWSTR
)RT_STRING
,
3583 (LPCWSTR
)LOCALE_ILANGUAGE
, enum_uilang_proc_w
,
3584 (LONG_PTR
)&enum_uilang
);
3588 INT WINAPI
GetGeoInfoW(GEOID GeoId
, GEOTYPE GeoType
, LPWSTR lpGeoData
,
3589 int cchData
, LANGID language
)
3591 FIXME("%d %d %p %d %d\n", GeoId
, GeoType
, lpGeoData
, cchData
, language
);
3595 INT WINAPI
GetGeoInfoA(GEOID GeoId
, GEOTYPE GeoType
, LPSTR lpGeoData
,
3596 int cchData
, LANGID language
)
3598 FIXME("%d %d %p %d %d\n", GeoId
, GeoType
, lpGeoData
, cchData
, language
);