mshtml: Moved add_script_runner call to push_mutation_queue.
[wine] / dlls / msvcrt / locale.c
1 /*
2  * msvcrt.dll locale functions
3  *
4  * Copyright 2000 Jon Griffiths
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <limits.h>
25 #include <locale.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "winnls.h"
33
34 #include "msvcrt.h"
35 #include "mtdll.h"
36
37 #include "wine/debug.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
40
41 /* FIXME: Need to hold locale for each LC_* type and aggregate
42  * string to produce lc_all.
43  */
44 #define MAX_ELEM_LEN 64 /* Max length of country/language/CP string */
45 #define MAX_LOCALE_LENGTH 256
46 char MSVCRT_current_lc_all[MAX_LOCALE_LENGTH] = { 0 };
47 LCID MSVCRT_current_lc_all_lcid = 0;
48 int MSVCRT___lc_codepage = 0;
49 int MSVCRT___lc_collate_cp = 0;
50 HANDLE MSVCRT___lc_handle[MSVCRT_LC_MAX - MSVCRT_LC_MIN + 1] = { 0 };
51 unsigned char charmax = CHAR_MAX;
52
53 /* MT */
54 #define LOCK_LOCALE   _mlock(_SETLOCALE_LOCK);
55 #define UNLOCK_LOCALE _munlock(_SETLOCALE_LOCK);
56
57 #define MSVCRT_LEADBYTE  0x8000
58
59 /* Friendly country strings & iso codes for synonym support.
60  * Based on MS documentation for setlocale().
61  */
62 static const char * const _country_synonyms[] =
63 {
64   "Hong Kong","HK",
65   "Hong-Kong","HK",
66   "New Zealand","NZ",
67   "New-Zealand","NZ",
68   "PR China","CN",
69   "PR-China","CN",
70   "United Kingdom","GB",
71   "United-Kingdom","GB",
72   "Britain","GB",
73   "England","GB",
74   "Great Britain","GB",
75   "United States","US",
76   "United-States","US",
77   "America","US"
78 };
79
80 /* INTERNAL: Map a synonym to an ISO code */
81 static void remap_synonym(char *name)
82 {
83   unsigned int i;
84   for (i = 0; i < sizeof(_country_synonyms)/sizeof(char*); i += 2 )
85   {
86     if (!strcasecmp(_country_synonyms[i],name))
87     {
88       TRACE(":Mapping synonym %s to %s\n",name,_country_synonyms[i+1]);
89       name[0] = _country_synonyms[i+1][0];
90       name[1] = _country_synonyms[i+1][1];
91       name[2] = '\0';
92       return;
93     }
94   }
95 }
96
97 /* Note: Flags are weighted in order of matching importance */
98 #define FOUND_LANGUAGE         0x4
99 #define FOUND_COUNTRY          0x2
100 #define FOUND_CODEPAGE         0x1
101
102 typedef struct {
103   char search_language[MAX_ELEM_LEN];
104   char search_country[MAX_ELEM_LEN];
105   char search_codepage[MAX_ELEM_LEN];
106   char found_language[MAX_ELEM_LEN];
107   char found_country[MAX_ELEM_LEN];
108   char found_codepage[MAX_ELEM_LEN];
109   unsigned int match_flags;
110   LANGID found_lang_id;
111 } locale_search_t;
112
113 #define CONTINUE_LOOKING TRUE
114 #define STOP_LOOKING     FALSE
115
116 /* INTERNAL: Get and compare locale info with a given string */
117 static int compare_info(LCID lcid, DWORD flags, char* buff, const char* cmp)
118 {
119   buff[0] = 0;
120   GetLocaleInfoA(lcid, flags|LOCALE_NOUSEROVERRIDE,buff, MAX_ELEM_LEN);
121   if (!buff[0] || !cmp[0])
122     return 0;
123   /* Partial matches are allowed, e.g. "Germ" matches "Germany" */
124   return !strncasecmp(cmp, buff, strlen(cmp));
125 }
126
127 static BOOL CALLBACK
128 find_best_locale_proc(HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
129 {
130   locale_search_t *res = (locale_search_t *)lParam;
131   const LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
132   char buff[MAX_ELEM_LEN];
133   unsigned int flags = 0;
134
135   if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
136     return CONTINUE_LOOKING;
137
138   /* Check Language */
139   if (compare_info(lcid,LOCALE_SISO639LANGNAME,buff,res->search_language) ||
140       compare_info(lcid,LOCALE_SABBREVLANGNAME,buff,res->search_language) ||
141       compare_info(lcid,LOCALE_SENGLANGUAGE,buff,res->search_language))
142   {
143     TRACE(":Found language: %s->%s\n", res->search_language, buff);
144     flags |= FOUND_LANGUAGE;
145     memcpy(res->found_language,res->search_language,MAX_ELEM_LEN);
146   }
147   else if (res->match_flags & FOUND_LANGUAGE)
148   {
149     return CONTINUE_LOOKING;
150   }
151
152   /* Check Country */
153   if (compare_info(lcid,LOCALE_SISO3166CTRYNAME,buff,res->search_country) ||
154       compare_info(lcid,LOCALE_SABBREVCTRYNAME,buff,res->search_country) ||
155       compare_info(lcid,LOCALE_SENGCOUNTRY,buff,res->search_country))
156   {
157     TRACE("Found country:%s->%s\n", res->search_country, buff);
158     flags |= FOUND_COUNTRY;
159     memcpy(res->found_country,res->search_country,MAX_ELEM_LEN);
160   }
161   else if (res->match_flags & FOUND_COUNTRY)
162   {
163     return CONTINUE_LOOKING;
164   }
165
166   /* Check codepage */
167   if (compare_info(lcid,LOCALE_IDEFAULTCODEPAGE,buff,res->search_codepage) ||
168       (compare_info(lcid,LOCALE_IDEFAULTANSICODEPAGE,buff,res->search_codepage)))
169   {
170     TRACE("Found codepage:%s->%s\n", res->search_codepage, buff);
171     flags |= FOUND_CODEPAGE;
172     memcpy(res->found_codepage,res->search_codepage,MAX_ELEM_LEN);
173   }
174   else if (res->match_flags & FOUND_CODEPAGE)
175   {
176     return CONTINUE_LOOKING;
177   }
178
179   if (flags > res->match_flags)
180   {
181     /* Found a better match than previously */
182     res->match_flags = flags;
183     res->found_lang_id = LangID;
184   }
185   if ((flags & (FOUND_LANGUAGE | FOUND_COUNTRY | FOUND_CODEPAGE)) ==
186         (FOUND_LANGUAGE | FOUND_COUNTRY | FOUND_CODEPAGE))
187   {
188     TRACE(":found exact locale match\n");
189     return STOP_LOOKING;
190   }
191   return CONTINUE_LOOKING;
192 }
193
194 extern int atoi(const char *);
195
196 /* Internal: Find the LCID for a locale specification */
197 static LCID MSVCRT_locale_to_LCID(locale_search_t* locale)
198 {
199   LCID lcid;
200   EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), (LPSTR)RT_STRING,
201                          (LPCSTR)LOCALE_ILANGUAGE,find_best_locale_proc,
202                          (LONG_PTR)locale);
203
204   if (!locale->match_flags)
205     return 0;
206
207   /* If we were given something that didn't match, fail */
208   if (locale->search_country[0] && !(locale->match_flags & FOUND_COUNTRY))
209     return 0;
210
211   lcid =  MAKELCID(locale->found_lang_id, SORT_DEFAULT);
212
213   /* Populate partial locale, translating LCID to locale string elements */
214   if (!locale->found_codepage[0])
215   {
216     /* Even if a codepage is not enumerated for a locale
217      * it can be set if valid */
218     if (locale->search_codepage[0])
219     {
220       if (IsValidCodePage(atoi(locale->search_codepage)))
221         memcpy(locale->found_codepage,locale->search_codepage,MAX_ELEM_LEN);
222       else
223       {
224         /* Special codepage values: OEM & ANSI */
225         if (strcasecmp(locale->search_codepage,"OCP"))
226         {
227           GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE,
228                          locale->found_codepage, MAX_ELEM_LEN);
229         }
230         if (strcasecmp(locale->search_codepage,"ACP"))
231         {
232           GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE,
233                          locale->found_codepage, MAX_ELEM_LEN);
234         }
235         else
236           return 0;
237
238         if (!atoi(locale->found_codepage))
239            return 0;
240       }
241     }
242     else
243     {
244       /* Prefer ANSI codepages if present */
245       GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE,
246                      locale->found_codepage, MAX_ELEM_LEN);
247       if (!locale->found_codepage[0] || !atoi(locale->found_codepage))
248           GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE,
249                          locale->found_codepage, MAX_ELEM_LEN);
250     }
251   }
252   GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE|LOCALE_NOUSEROVERRIDE,
253                  locale->found_language, MAX_ELEM_LEN);
254   GetLocaleInfoA(lcid, LOCALE_SENGCOUNTRY|LOCALE_NOUSEROVERRIDE,
255                  locale->found_country, MAX_ELEM_LEN);
256   return lcid;
257 }
258
259 /* INTERNAL: Set ctype behaviour for a codepage */
260 static void msvcrt_set_ctype(unsigned int codepage, LCID lcid)
261 {
262   CPINFO cp;
263
264   memset(&cp, 0, sizeof(CPINFO));
265
266   if (GetCPInfo(codepage, &cp))
267   {
268     int i;
269     char str[3];
270     unsigned char *traverse = cp.LeadByte;
271
272     memset(MSVCRT_current_ctype, 0, sizeof(MSVCRT__ctype));
273     MSVCRT___lc_codepage = codepage;
274     MSVCRT___lc_collate_cp = codepage;
275
276     /* Switch ctype macros to MBCS if needed */
277     MSVCRT___mb_cur_max = cp.MaxCharSize;
278
279     /* Set remaining ctype flags: FIXME: faster way to do this? */
280     str[1] = str[2] = 0;
281     for (i = 0; i < 256; i++)
282     {
283       if (!(MSVCRT__pctype[i] & MSVCRT_LEADBYTE))
284       {
285         str[0] = i;
286         GetStringTypeA(lcid, CT_CTYPE1, str, 1, MSVCRT__pctype + i);
287       }
288     }
289
290     /* Set leadbyte flags */
291     while (traverse[0] || traverse[1])
292     {
293       for( i = traverse[0]; i <= traverse[1]; i++ )
294         MSVCRT_current_ctype[i+1] |= MSVCRT_LEADBYTE;
295       traverse += 2;
296     };
297   }
298 }
299
300
301 /*********************************************************************
302  *              setlocale (MSVCRT.@)
303  */
304 char* CDECL MSVCRT_setlocale(int category, const char* locale)
305 {
306   LCID lcid = 0;
307   locale_search_t lc;
308   int haveLang, haveCountry, haveCP;
309   char* next;
310   int lc_all = 0;
311
312   TRACE("(%d %s)\n",category,locale);
313
314   if (category < MSVCRT_LC_MIN || category > MSVCRT_LC_MAX)
315     return NULL;
316
317   if (locale == NULL)
318   {
319     /* Report the current Locale */
320     return MSVCRT_current_lc_all;
321   }
322
323   LOCK_LOCALE;
324
325   if (locale[0] == 'L' && locale[1] == 'C' && locale[2] == '_')
326   {
327     FIXME(":restore previous locale not implemented!\n");
328     /* FIXME: Easiest way to do this is parse the string and
329      * call this function recursively with its elements,
330      * Where they differ for each lc_ type.
331      */
332     UNLOCK_LOCALE;
333     return MSVCRT_current_lc_all;
334   }
335
336   /* Default Locale: Special case handling */
337   if (!strlen(locale) || ((toupper(locale[0]) == 'C') && !locale[1]))
338   {
339     MSVCRT_current_lc_all[0] = 'C';
340     MSVCRT_current_lc_all[1] = '\0';
341     MSVCRT___lc_codepage = GetACP();
342     MSVCRT___lc_collate_cp = GetACP();
343
344     switch (category) {
345     case MSVCRT_LC_ALL:
346       lc_all = 1; /* Fall through all cases ... */
347     case MSVCRT_LC_COLLATE:
348       if (!lc_all) break;
349     case MSVCRT_LC_CTYPE:
350       /* Restore C locale ctype info */
351       MSVCRT___mb_cur_max = 1;
352       memcpy(MSVCRT_current_ctype, MSVCRT__ctype, sizeof(MSVCRT__ctype));
353       if (!lc_all) break;
354     case MSVCRT_LC_MONETARY:
355       if (!lc_all) break;
356     case MSVCRT_LC_NUMERIC:
357       if (!lc_all) break;
358     case MSVCRT_LC_TIME:
359       break;
360     }
361     UNLOCK_LOCALE;
362     return MSVCRT_current_lc_all;
363   }
364
365   /* Get locale elements */
366   haveLang = haveCountry = haveCP = 0;
367   memset(&lc,0,sizeof(lc));
368
369   next = strchr(locale,'_');
370   if (next && next != locale)
371   {
372     haveLang = 1;
373     memcpy(lc.search_language,locale,next-locale);
374     locale += next-locale+1;
375   }
376
377   next = strchr(locale,'.');
378   if (next)
379   {
380     haveCP = 1;
381     if (next == locale)
382     {
383       locale++;
384       lstrcpynA(lc.search_codepage, locale, MAX_ELEM_LEN);
385     }
386     else
387     {
388       if (haveLang)
389       {
390         haveCountry = 1;
391         memcpy(lc.search_country,locale,next-locale);
392         locale += next-locale+1;
393       }
394       else
395       {
396         haveLang = 1;
397         memcpy(lc.search_language,locale,next-locale);
398         locale += next-locale+1;
399       }
400       lstrcpynA(lc.search_codepage, locale, MAX_ELEM_LEN);
401     }
402   }
403   else
404   {
405     if (haveLang)
406     {
407       haveCountry = 1;
408       lstrcpynA(lc.search_country, locale, MAX_ELEM_LEN);
409     }
410     else
411     {
412       haveLang = 1;
413       lstrcpynA(lc.search_language, locale, MAX_ELEM_LEN);
414     }
415   }
416
417   if (haveCountry)
418     remap_synonym(lc.search_country);
419
420   if (haveCP && !haveCountry && !haveLang)
421   {
422     FIXME(":Codepage only locale not implemented\n");
423     /* FIXME: Use default lang/country and skip locale_to_LCID()
424      * call below...
425      */
426     UNLOCK_LOCALE;
427     return NULL;
428   }
429
430   lcid = MSVCRT_locale_to_LCID(&lc);
431
432   TRACE(":found LCID %d\n",lcid);
433
434   if (lcid == 0)
435   {
436     UNLOCK_LOCALE;
437     return NULL;
438   }
439
440   MSVCRT_current_lc_all_lcid = lcid;
441
442   snprintf(MSVCRT_current_lc_all,MAX_LOCALE_LENGTH,"%s_%s.%s",
443            lc.found_language,lc.found_country,lc.found_codepage);
444
445   switch (category) {
446   case MSVCRT_LC_ALL:
447     lc_all = 1; /* Fall through all cases ... */
448   case MSVCRT_LC_COLLATE:
449     if (!lc_all) break;
450   case MSVCRT_LC_CTYPE:
451     msvcrt_set_ctype(atoi(lc.found_codepage),lcid);
452     if (!lc_all) break;
453   case MSVCRT_LC_MONETARY:
454     if (!lc_all) break;
455   case MSVCRT_LC_NUMERIC:
456     if (!lc_all) break;
457   case MSVCRT_LC_TIME:
458     break;
459   }
460   UNLOCK_LOCALE;
461   return MSVCRT_current_lc_all;
462 }
463
464 /*********************************************************************
465  *              setlocale (MSVCRT.@)
466  */
467 MSVCRT_wchar_t* CDECL MSVCRT__wsetlocale(int category, const MSVCRT_wchar_t* locale)
468 {
469   static MSVCRT_wchar_t fake[] = {
470     'E','n','g','l','i','s','h','_','U','n','i','t','e','d',' ',
471     'S','t','a','t','e','s','.','1','2','5','2',0 };
472
473   FIXME("%d %s\n", category, debugstr_w(locale));
474
475   return fake;
476 }
477
478 /*********************************************************************
479  *              _Getdays (MSVCRT.@)
480  */
481 const char* CDECL _Getdays(void)
482 {
483   static const char MSVCRT_days[] = ":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:"
484                             "Wednesday:Thu:Thursday:Fri:Friday:Sat:Saturday";
485   /* FIXME: Use locale */
486   TRACE("(void) semi-stub\n");
487   return MSVCRT_days;
488 }
489
490 /*********************************************************************
491  *              _Getmonths (MSVCRT.@)
492  */
493 const char* CDECL _Getmonths(void)
494 {
495   static const char MSVCRT_months[] = ":Jan:January:Feb:February:Mar:March:Apr:"
496                 "April:May:May:Jun:June:Jul:July:Aug:August:Sep:September:Oct:"
497                 "October:Nov:November:Dec:December";
498   /* FIXME: Use locale */
499   TRACE("(void) semi-stub\n");
500   return MSVCRT_months;
501 }
502
503 /*********************************************************************
504  *              _Gettnames (MSVCRT.@)
505  */
506 const char* CDECL _Gettnames(void)
507 {
508   /* FIXME: */
509   TRACE("(void) stub\n");
510   return "";
511 }
512
513 /*********************************************************************
514  *              _Strftime (MSVCRT.@)
515  */
516 const char* CDECL _Strftime(char *out, unsigned int len, const char *fmt,
517                             const void *tm, void *foo)
518 {
519   /* FIXME: */
520   TRACE("(%p %d %s %p %p) stub\n", out, len, fmt, tm, foo);
521   return "";
522 }
523
524 /*********************************************************************
525  *              __crtLCMapStringA (MSVCRT.@)
526  */
527 int CDECL __crtLCMapStringA(
528   LCID lcid, DWORD mapflags, const char* src, int srclen, char* dst,
529   int dstlen, unsigned int codepage, int xflag
530 ) {
531   FIXME("(lcid %x, flags %x, %s(%d), %p(%d), %x, %d), partial stub!\n",
532         lcid,mapflags,src,srclen,dst,dstlen,codepage,xflag);
533   /* FIXME: A bit incorrect. But msvcrt itself just converts its
534    * arguments to wide strings and then calls LCMapStringW
535    */
536   return LCMapStringA(lcid,mapflags,src,srclen,dst,dstlen);
537 }
538
539 /*********************************************************************
540  *              __crtCompareStringA (MSVCRT.@)
541  */
542 int CDECL __crtCompareStringA( LCID lcid, DWORD flags, const char *src1, int len1,
543                                const char *src2, int len2 )
544 {
545     FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
546           lcid, flags, debugstr_a(src1), len1, debugstr_a(src2), len2 );
547     /* FIXME: probably not entirely right */
548     return CompareStringA( lcid, flags, src1, len1, src2, len2 );
549 }
550
551 /*********************************************************************
552  *              __crtCompareStringW (MSVCRT.@)
553  */
554 int CDECL __crtCompareStringW( LCID lcid, DWORD flags, const MSVCRT_wchar_t *src1, int len1,
555                                const MSVCRT_wchar_t *src2, int len2 )
556 {
557     FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
558           lcid, flags, debugstr_w(src1), len1, debugstr_w(src2), len2 );
559     /* FIXME: probably not entirely right */
560     return CompareStringW( lcid, flags, src1, len1, src2, len2 );
561 }
562
563 /*********************************************************************
564  *              __crtGetLocaleInfoW (MSVCRT.@)
565  */
566 int CDECL __crtGetLocaleInfoW( LCID lcid, LCTYPE type, MSVCRT_wchar_t *buffer, int len )
567 {
568     FIXME("(lcid %x, type %x, %p(%d), partial stub\n", lcid, type, buffer, len );
569     /* FIXME: probably not entirely right */
570     return GetLocaleInfoW( lcid, type, buffer, len );
571 }
572
573 /*********************************************************************
574  *              localeconv (MSVCRT.@)
575  */
576 struct MSVCRT_lconv * CDECL MSVCRT_localeconv(void)
577 {
578     static struct MSVCRT_lconv xlconv;
579     struct lconv *ylconv = localeconv();
580
581     xlconv.decimal_point     = ylconv->decimal_point;
582     xlconv.thousands_sep     = ylconv->thousands_sep;
583     xlconv.grouping          = ylconv->grouping;  /* FIXME: fixup charmax here too */
584     xlconv.int_curr_symbol   = ylconv->int_curr_symbol;
585     xlconv.currency_symbol   = ylconv->currency_symbol;
586     xlconv.mon_decimal_point = ylconv->mon_decimal_point;
587     xlconv.mon_thousands_sep = ylconv->mon_thousands_sep;
588     xlconv.mon_grouping      = ylconv->mon_grouping;
589     xlconv.positive_sign     = ylconv->positive_sign;
590     xlconv.negative_sign     = ylconv->negative_sign;
591     xlconv.int_frac_digits   = ylconv->int_frac_digits;
592     xlconv.frac_digits       = ylconv->frac_digits;
593     xlconv.p_cs_precedes     = ylconv->p_cs_precedes;
594     xlconv.p_sep_by_space    = ylconv->p_sep_by_space;
595     xlconv.n_cs_precedes     = ylconv->n_cs_precedes;
596     xlconv.n_sep_by_space    = ylconv->n_sep_by_space;
597     xlconv.p_sign_posn       = ylconv->p_sign_posn;
598     xlconv.n_sign_posn       = ylconv->n_sign_posn;
599
600     if (ylconv->int_frac_digits == CHAR_MAX) xlconv.int_frac_digits = charmax;
601     if (ylconv->frac_digits == CHAR_MAX)     xlconv.frac_digits = charmax;
602     if (ylconv->p_cs_precedes == CHAR_MAX)   xlconv.p_cs_precedes = charmax;
603     if (ylconv->p_sep_by_space == CHAR_MAX)  xlconv.p_sep_by_space = charmax;
604     if (ylconv->n_cs_precedes == CHAR_MAX)   xlconv.n_cs_precedes = charmax;
605     if (ylconv->n_sep_by_space == CHAR_MAX)  xlconv.n_sep_by_space = charmax;
606     if (ylconv->p_sign_posn == CHAR_MAX)     xlconv.p_sign_posn = charmax;
607     if (ylconv->n_sign_posn == CHAR_MAX)     xlconv.n_sign_posn = charmax;
608
609     return &xlconv;
610 }
611
612 /*********************************************************************
613  *              __lconv_init (MSVCRT.@)
614  */
615 void CDECL __lconv_init(void)
616 {
617     /* this is used to make chars unsigned */
618     charmax = 255;
619 }
620
621 /*********************************************************************
622  *      ___lc_handle_func (MSVCRT.@)
623  */
624 HANDLE * CDECL ___lc_handle_func(void)
625 {
626     return MSVCRT___lc_handle;
627 }
628
629 /*********************************************************************
630  *      ___lc_codepage_func (MSVCRT.@)
631  */
632 int CDECL ___lc_codepage_func(void)
633 {
634     return MSVCRT___lc_codepage;
635 }
636
637 /*********************************************************************
638  *      ___lc_collate_cp_func (MSVCRT.@)
639  */
640 int CDECL ___lc_collate_cp_func(void)
641 {
642     return MSVCRT___lc_collate_cp;
643 }