1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1998 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 1998-1999 Tor Lillqvist
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GLib Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GLib at ftp://ftp.gtk.org/pub/gtk/.
29 * MT safe for the unix part, FIXME: make the win32 part MT safe as well.
34 #include "glibconfig.h"
42 #define STRICT /* Strict typing, please */
58 #include <sys/cygwin.h>
64 g_win32_ftruncate (gint fd
,
67 return _chsize (fd
, size
);
75 * The setlocale() function in the Microsoft C library uses locale
76 * names of the form "English_United States.1252" etc. We want the
77 * UNIXish standard form "en_US", "zh_TW" etc. This function gets the
78 * current thread locale from Windows - without any encoding info -
79 * and returns it as a string of the above form for use in forming
80 * file names etc. The returned string should be deallocated with
83 * Returns: newly-allocated locale name.
86 /* Borrowed from GNU gettext 0.13.1: */
87 /* Mingw headers don't have latest language and sublanguage codes. */
88 #ifndef LANG_AFRIKAANS
89 #define LANG_AFRIKAANS 0x36
92 #define LANG_ALBANIAN 0x1c
95 #define LANG_AMHARIC 0x5e
98 #define LANG_ARABIC 0x01
100 #ifndef LANG_ARMENIAN
101 #define LANG_ARMENIAN 0x2b
103 #ifndef LANG_ASSAMESE
104 #define LANG_ASSAMESE 0x4d
107 #define LANG_AZERI 0x2c
110 #define LANG_BASQUE 0x2d
112 #ifndef LANG_BELARUSIAN
113 #define LANG_BELARUSIAN 0x23
116 #define LANG_BENGALI 0x45
119 #define LANG_BURMESE 0x55
121 #ifndef LANG_CAMBODIAN
122 #define LANG_CAMBODIAN 0x53
125 #define LANG_CATALAN 0x03
127 #ifndef LANG_CHEROKEE
128 #define LANG_CHEROKEE 0x5c
131 #define LANG_DIVEHI 0x65
134 #define LANG_EDO 0x66
136 #ifndef LANG_ESTONIAN
137 #define LANG_ESTONIAN 0x25
139 #ifndef LANG_FAEROESE
140 #define LANG_FAEROESE 0x38
143 #define LANG_FARSI 0x29
146 #define LANG_FRISIAN 0x62
148 #ifndef LANG_FULFULDE
149 #define LANG_FULFULDE 0x67
152 #define LANG_GAELIC 0x3c
154 #ifndef LANG_GALICIAN
155 #define LANG_GALICIAN 0x56
157 #ifndef LANG_GEORGIAN
158 #define LANG_GEORGIAN 0x37
161 #define LANG_GUARANI 0x74
163 #ifndef LANG_GUJARATI
164 #define LANG_GUJARATI 0x47
167 #define LANG_HAUSA 0x68
169 #ifndef LANG_HAWAIIAN
170 #define LANG_HAWAIIAN 0x75
173 #define LANG_HEBREW 0x0d
176 #define LANG_HINDI 0x39
179 #define LANG_IBIBIO 0x69
182 #define LANG_IGBO 0x70
184 #ifndef LANG_INDONESIAN
185 #define LANG_INDONESIAN 0x21
187 #ifndef LANG_INUKTITUT
188 #define LANG_INUKTITUT 0x5d
191 #define LANG_KANNADA 0x4b
194 #define LANG_KANURI 0x71
196 #ifndef LANG_KASHMIRI
197 #define LANG_KASHMIRI 0x60
200 #define LANG_KAZAK 0x3f
203 #define LANG_KONKANI 0x57
206 #define LANG_KYRGYZ 0x40
209 #define LANG_LAO 0x54
212 #define LANG_LATIN 0x76
215 #define LANG_LATVIAN 0x26
217 #ifndef LANG_LITHUANIAN
218 #define LANG_LITHUANIAN 0x27
220 #ifndef LANG_MACEDONIAN
221 #define LANG_MACEDONIAN 0x2f
224 #define LANG_MALAY 0x3e
226 #ifndef LANG_MALAYALAM
227 #define LANG_MALAYALAM 0x4c
230 #define LANG_MALTESE 0x3a
232 #ifndef LANG_MANIPURI
233 #define LANG_MANIPURI 0x58
236 #define LANG_MARATHI 0x4e
238 #ifndef LANG_MONGOLIAN
239 #define LANG_MONGOLIAN 0x50
242 #define LANG_NEPALI 0x61
245 #define LANG_ORIYA 0x48
248 #define LANG_OROMO 0x72
250 #ifndef LANG_PAPIAMENTU
251 #define LANG_PAPIAMENTU 0x79
254 #define LANG_PASHTO 0x63
257 #define LANG_PUNJABI 0x46
259 #ifndef LANG_RHAETO_ROMANCE
260 #define LANG_RHAETO_ROMANCE 0x17
263 #define LANG_SAAMI 0x3b
265 #ifndef LANG_SANSKRIT
266 #define LANG_SANSKRIT 0x4f
269 #define LANG_SERBIAN 0x1a
272 #define LANG_SINDHI 0x59
274 #ifndef LANG_SINHALESE
275 #define LANG_SINHALESE 0x5b
278 #define LANG_SLOVAK 0x1b
281 #define LANG_SOMALI 0x77
284 #define LANG_SORBIAN 0x2e
287 #define LANG_SUTU 0x30
290 #define LANG_SWAHILI 0x41
293 #define LANG_SYRIAC 0x5a
296 #define LANG_TAGALOG 0x64
299 #define LANG_TAJIK 0x28
301 #ifndef LANG_TAMAZIGHT
302 #define LANG_TAMAZIGHT 0x5f
305 #define LANG_TAMIL 0x49
308 #define LANG_TATAR 0x44
311 #define LANG_TELUGU 0x4a
314 #define LANG_THAI 0x1e
317 #define LANG_TIBETAN 0x51
319 #ifndef LANG_TIGRINYA
320 #define LANG_TIGRINYA 0x73
323 #define LANG_TSONGA 0x31
326 #define LANG_TSWANA 0x32
329 #define LANG_TURKMEN 0x42
331 #ifndef LANG_UKRAINIAN
332 #define LANG_UKRAINIAN 0x22
335 #define LANG_URDU 0x20
338 #define LANG_UZBEK 0x43
341 #define LANG_VENDA 0x33
343 #ifndef LANG_VIETNAMESE
344 #define LANG_VIETNAMESE 0x2a
347 #define LANG_WELSH 0x52
350 #define LANG_XHOSA 0x34
356 #define LANG_YIDDISH 0x3d
359 #define LANG_YORUBA 0x6a
362 #define LANG_ZULU 0x35
364 #ifndef SUBLANG_ARABIC_SAUDI_ARABIA
365 #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
367 #ifndef SUBLANG_ARABIC_IRAQ
368 #define SUBLANG_ARABIC_IRAQ 0x02
370 #ifndef SUBLANG_ARABIC_EGYPT
371 #define SUBLANG_ARABIC_EGYPT 0x03
373 #ifndef SUBLANG_ARABIC_LIBYA
374 #define SUBLANG_ARABIC_LIBYA 0x04
376 #ifndef SUBLANG_ARABIC_ALGERIA
377 #define SUBLANG_ARABIC_ALGERIA 0x05
379 #ifndef SUBLANG_ARABIC_MOROCCO
380 #define SUBLANG_ARABIC_MOROCCO 0x06
382 #ifndef SUBLANG_ARABIC_TUNISIA
383 #define SUBLANG_ARABIC_TUNISIA 0x07
385 #ifndef SUBLANG_ARABIC_OMAN
386 #define SUBLANG_ARABIC_OMAN 0x08
388 #ifndef SUBLANG_ARABIC_YEMEN
389 #define SUBLANG_ARABIC_YEMEN 0x09
391 #ifndef SUBLANG_ARABIC_SYRIA
392 #define SUBLANG_ARABIC_SYRIA 0x0a
394 #ifndef SUBLANG_ARABIC_JORDAN
395 #define SUBLANG_ARABIC_JORDAN 0x0b
397 #ifndef SUBLANG_ARABIC_LEBANON
398 #define SUBLANG_ARABIC_LEBANON 0x0c
400 #ifndef SUBLANG_ARABIC_KUWAIT
401 #define SUBLANG_ARABIC_KUWAIT 0x0d
403 #ifndef SUBLANG_ARABIC_UAE
404 #define SUBLANG_ARABIC_UAE 0x0e
406 #ifndef SUBLANG_ARABIC_BAHRAIN
407 #define SUBLANG_ARABIC_BAHRAIN 0x0f
409 #ifndef SUBLANG_ARABIC_QATAR
410 #define SUBLANG_ARABIC_QATAR 0x10
412 #ifndef SUBLANG_AZERI_LATIN
413 #define SUBLANG_AZERI_LATIN 0x01
415 #ifndef SUBLANG_AZERI_CYRILLIC
416 #define SUBLANG_AZERI_CYRILLIC 0x02
418 #ifndef SUBLANG_BENGALI_INDIA
419 #define SUBLANG_BENGALI_INDIA 0x00
421 #ifndef SUBLANG_BENGALI_BANGLADESH
422 #define SUBLANG_BENGALI_BANGLADESH 0x01
424 #ifndef SUBLANG_CHINESE_MACAU
425 #define SUBLANG_CHINESE_MACAU 0x05
427 #ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
428 #define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
430 #ifndef SUBLANG_ENGLISH_JAMAICA
431 #define SUBLANG_ENGLISH_JAMAICA 0x08
433 #ifndef SUBLANG_ENGLISH_CARIBBEAN
434 #define SUBLANG_ENGLISH_CARIBBEAN 0x09
436 #ifndef SUBLANG_ENGLISH_BELIZE
437 #define SUBLANG_ENGLISH_BELIZE 0x0a
439 #ifndef SUBLANG_ENGLISH_TRINIDAD
440 #define SUBLANG_ENGLISH_TRINIDAD 0x0b
442 #ifndef SUBLANG_ENGLISH_ZIMBABWE
443 #define SUBLANG_ENGLISH_ZIMBABWE 0x0c
445 #ifndef SUBLANG_ENGLISH_PHILIPPINES
446 #define SUBLANG_ENGLISH_PHILIPPINES 0x0d
448 #ifndef SUBLANG_ENGLISH_INDONESIA
449 #define SUBLANG_ENGLISH_INDONESIA 0x0e
451 #ifndef SUBLANG_ENGLISH_HONGKONG
452 #define SUBLANG_ENGLISH_HONGKONG 0x0f
454 #ifndef SUBLANG_ENGLISH_INDIA
455 #define SUBLANG_ENGLISH_INDIA 0x10
457 #ifndef SUBLANG_ENGLISH_MALAYSIA
458 #define SUBLANG_ENGLISH_MALAYSIA 0x11
460 #ifndef SUBLANG_ENGLISH_SINGAPORE
461 #define SUBLANG_ENGLISH_SINGAPORE 0x12
463 #ifndef SUBLANG_FRENCH_LUXEMBOURG
464 #define SUBLANG_FRENCH_LUXEMBOURG 0x05
466 #ifndef SUBLANG_FRENCH_MONACO
467 #define SUBLANG_FRENCH_MONACO 0x06
469 #ifndef SUBLANG_FRENCH_WESTINDIES
470 #define SUBLANG_FRENCH_WESTINDIES 0x07
472 #ifndef SUBLANG_FRENCH_REUNION
473 #define SUBLANG_FRENCH_REUNION 0x08
475 #ifndef SUBLANG_FRENCH_CONGO
476 #define SUBLANG_FRENCH_CONGO 0x09
478 #ifndef SUBLANG_FRENCH_SENEGAL
479 #define SUBLANG_FRENCH_SENEGAL 0x0a
481 #ifndef SUBLANG_FRENCH_CAMEROON
482 #define SUBLANG_FRENCH_CAMEROON 0x0b
484 #ifndef SUBLANG_FRENCH_COTEDIVOIRE
485 #define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
487 #ifndef SUBLANG_FRENCH_MALI
488 #define SUBLANG_FRENCH_MALI 0x0d
490 #ifndef SUBLANG_FRENCH_MOROCCO
491 #define SUBLANG_FRENCH_MOROCCO 0x0e
493 #ifndef SUBLANG_FRENCH_HAITI
494 #define SUBLANG_FRENCH_HAITI 0x0f
496 #ifndef SUBLANG_GERMAN_LUXEMBOURG
497 #define SUBLANG_GERMAN_LUXEMBOURG 0x04
499 #ifndef SUBLANG_GERMAN_LIECHTENSTEIN
500 #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
502 #ifndef SUBLANG_KASHMIRI_INDIA
503 #define SUBLANG_KASHMIRI_INDIA 0x02
505 #ifndef SUBLANG_MALAY_MALAYSIA
506 #define SUBLANG_MALAY_MALAYSIA 0x01
508 #ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
509 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
511 #ifndef SUBLANG_NEPALI_INDIA
512 #define SUBLANG_NEPALI_INDIA 0x02
514 #ifndef SUBLANG_PUNJABI_INDIA
515 #define SUBLANG_PUNJABI_INDIA 0x00
517 #ifndef SUBLANG_PUNJABI_PAKISTAN
518 #define SUBLANG_PUNJABI_PAKISTAN 0x01
520 #ifndef SUBLANG_ROMANIAN_ROMANIA
521 #define SUBLANG_ROMANIAN_ROMANIA 0x00
523 #ifndef SUBLANG_ROMANIAN_MOLDOVA
524 #define SUBLANG_ROMANIAN_MOLDOVA 0x01
526 #ifndef SUBLANG_SERBIAN_LATIN
527 #define SUBLANG_SERBIAN_LATIN 0x02
529 #ifndef SUBLANG_SERBIAN_CYRILLIC
530 #define SUBLANG_SERBIAN_CYRILLIC 0x03
532 #ifndef SUBLANG_SINDHI_INDIA
533 #define SUBLANG_SINDHI_INDIA 0x00
535 #ifndef SUBLANG_SINDHI_PAKISTAN
536 #define SUBLANG_SINDHI_PAKISTAN 0x01
538 #ifndef SUBLANG_SPANISH_GUATEMALA
539 #define SUBLANG_SPANISH_GUATEMALA 0x04
541 #ifndef SUBLANG_SPANISH_COSTA_RICA
542 #define SUBLANG_SPANISH_COSTA_RICA 0x05
544 #ifndef SUBLANG_SPANISH_PANAMA
545 #define SUBLANG_SPANISH_PANAMA 0x06
547 #ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
548 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
550 #ifndef SUBLANG_SPANISH_VENEZUELA
551 #define SUBLANG_SPANISH_VENEZUELA 0x08
553 #ifndef SUBLANG_SPANISH_COLOMBIA
554 #define SUBLANG_SPANISH_COLOMBIA 0x09
556 #ifndef SUBLANG_SPANISH_PERU
557 #define SUBLANG_SPANISH_PERU 0x0a
559 #ifndef SUBLANG_SPANISH_ARGENTINA
560 #define SUBLANG_SPANISH_ARGENTINA 0x0b
562 #ifndef SUBLANG_SPANISH_ECUADOR
563 #define SUBLANG_SPANISH_ECUADOR 0x0c
565 #ifndef SUBLANG_SPANISH_CHILE
566 #define SUBLANG_SPANISH_CHILE 0x0d
568 #ifndef SUBLANG_SPANISH_URUGUAY
569 #define SUBLANG_SPANISH_URUGUAY 0x0e
571 #ifndef SUBLANG_SPANISH_PARAGUAY
572 #define SUBLANG_SPANISH_PARAGUAY 0x0f
574 #ifndef SUBLANG_SPANISH_BOLIVIA
575 #define SUBLANG_SPANISH_BOLIVIA 0x10
577 #ifndef SUBLANG_SPANISH_EL_SALVADOR
578 #define SUBLANG_SPANISH_EL_SALVADOR 0x11
580 #ifndef SUBLANG_SPANISH_HONDURAS
581 #define SUBLANG_SPANISH_HONDURAS 0x12
583 #ifndef SUBLANG_SPANISH_NICARAGUA
584 #define SUBLANG_SPANISH_NICARAGUA 0x13
586 #ifndef SUBLANG_SPANISH_PUERTO_RICO
587 #define SUBLANG_SPANISH_PUERTO_RICO 0x14
589 #ifndef SUBLANG_SWEDISH_FINLAND
590 #define SUBLANG_SWEDISH_FINLAND 0x02
592 #ifndef SUBLANG_TAMAZIGHT_ARABIC
593 #define SUBLANG_TAMAZIGHT_ARABIC 0x01
595 #ifndef SUBLANG_TAMAZIGHT_LATIN
596 #define SUBLANG_TAMAZIGHT_LATIN 0x02
598 #ifndef SUBLANG_TIGRINYA_ETHIOPIA
599 #define SUBLANG_TIGRINYA_ETHIOPIA 0x00
601 #ifndef SUBLANG_TIGRINYA_ERITREA
602 #define SUBLANG_TIGRINYA_ERITREA 0x01
604 #ifndef SUBLANG_URDU_PAKISTAN
605 #define SUBLANG_URDU_PAKISTAN 0x01
607 #ifndef SUBLANG_URDU_INDIA
608 #define SUBLANG_URDU_INDIA 0x02
610 #ifndef SUBLANG_UZBEK_LATIN
611 #define SUBLANG_UZBEK_LATIN 0x01
613 #ifndef SUBLANG_UZBEK_CYRILLIC
614 #define SUBLANG_UZBEK_CYRILLIC 0x02
618 g_win32_getlocale (void)
624 gchar
*l
= "C", *sl
= NULL
;
627 /* Let the user override the system settings through environment
628 variables, as on POSIX systems. */
629 if (((ev
= getenv ("LC_ALL")) != NULL
&& ev
[0] != '\0')
630 || ((ev
= getenv ("LC_MESSAGES")) != NULL
&& ev
[0] != '\0')
631 || ((ev
= getenv ("LANG")) != NULL
&& ev
[0] != '\0'))
632 return g_strdup (ev
);
634 /* Use native Win32 API locale ID. */
635 lcid
= GetThreadLocale ();
637 /* Strip off the sorting rules, keep only the language part. */
638 langid
= LANGIDFROMLCID (lcid
);
640 /* Split into language and territory part. */
641 primary
= PRIMARYLANGID (langid
);
642 sub
= SUBLANGID (langid
);
645 case LANG_AFRIKAANS
: l
= "af"; sl
= "ZA"; break;
646 case LANG_ALBANIAN
: l
= "sq"; sl
= "AL"; break;
651 case SUBLANG_ARABIC_SAUDI_ARABIA
: sl
= "SA"; break;
652 case SUBLANG_ARABIC_IRAQ
: sl
= "IQ"; break;
653 case SUBLANG_ARABIC_EGYPT
: sl
= "EG"; break;
654 case SUBLANG_ARABIC_LIBYA
: sl
= "LY"; break;
655 case SUBLANG_ARABIC_ALGERIA
: sl
= "DZ"; break;
656 case SUBLANG_ARABIC_MOROCCO
: sl
= "MA"; break;
657 case SUBLANG_ARABIC_TUNISIA
: sl
= "TN"; break;
658 case SUBLANG_ARABIC_OMAN
: sl
= "OM"; break;
659 case SUBLANG_ARABIC_YEMEN
: sl
= "YE"; break;
660 case SUBLANG_ARABIC_SYRIA
: sl
= "SY"; break;
661 case SUBLANG_ARABIC_JORDAN
: sl
= "JO"; break;
662 case SUBLANG_ARABIC_LEBANON
: sl
= "LB"; break;
663 case SUBLANG_ARABIC_KUWAIT
: sl
= "KW"; break;
664 case SUBLANG_ARABIC_UAE
: sl
= "AE"; break;
665 case SUBLANG_ARABIC_BAHRAIN
: sl
= "BH"; break;
666 case SUBLANG_ARABIC_QATAR
: sl
= "QA"; break;
669 case LANG_ARMENIAN
: l
= "hy"; sl
= "AM"; break;
670 case LANG_ASSAMESE
: l
= "as"; sl
= "IN"; break;
675 /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
676 case SUBLANG_AZERI_LATIN
: sl
= "AZ@latin"; break;
677 case SUBLANG_AZERI_CYRILLIC
: sl
= "AZ@cyrillic"; break;
681 l
= "eu"; /* sl could be "ES" or "FR". */
683 case LANG_BELARUSIAN
: l
= "be"; sl
= "BY"; break;
688 case SUBLANG_BENGALI_INDIA
: sl
= "IN"; break;
689 case SUBLANG_BENGALI_BANGLADESH
: sl
= "BD"; break;
692 case LANG_BULGARIAN
: l
= "bg"; sl
= "BG"; break;
693 case LANG_BURMESE
: l
= "my"; sl
= "MM"; break;
694 case LANG_CAMBODIAN
: l
= "km"; sl
= "KH"; break;
695 case LANG_CATALAN
: l
= "ca"; sl
= "ES"; break;
700 case SUBLANG_CHINESE_TRADITIONAL
: sl
= "TW"; break;
701 case SUBLANG_CHINESE_SIMPLIFIED
: sl
= "CN"; break;
702 case SUBLANG_CHINESE_HONGKONG
: sl
= "HK"; break;
703 case SUBLANG_CHINESE_SINGAPORE
: sl
= "SG"; break;
704 case SUBLANG_CHINESE_MACAU
: sl
= "MO"; break;
707 case LANG_CROATIAN
: /* LANG_CROATIAN == LANG_SERBIAN */
710 /* FIXME: How to distinguish Croatian and Latin Serbian locales? */
711 case SUBLANG_SERBIAN_LATIN
: l
= "sr"; sl
= "@Latn"; break;
712 case SUBLANG_SERBIAN_CYRILLIC
: l
= "sr"; break;
713 default: l
= "hr"; sl
= "HR";
716 case LANG_CZECH
: l
= "cs"; sl
= "CZ"; break;
717 case LANG_DANISH
: l
= "da"; sl
= "DK"; break;
718 case LANG_DIVEHI
: l
= "div"; sl
= "MV"; break;
723 case SUBLANG_DUTCH
: sl
= "NL"; break;
724 case SUBLANG_DUTCH_BELGIAN
: sl
= "BE"; break;
731 case SUBLANG_ENGLISH_US
: sl
= "US"; break;
732 case SUBLANG_ENGLISH_UK
: sl
= "GB"; break;
733 case SUBLANG_ENGLISH_AUS
: sl
= "AU"; break;
734 case SUBLANG_ENGLISH_CAN
: sl
= "CA"; break;
735 case SUBLANG_ENGLISH_NZ
: sl
= "NZ"; break;
736 case SUBLANG_ENGLISH_EIRE
: sl
= "IE"; break;
737 case SUBLANG_ENGLISH_SOUTH_AFRICA
: sl
= "ZA"; break;
738 case SUBLANG_ENGLISH_JAMAICA
: sl
= "JM"; break;
739 case SUBLANG_ENGLISH_CARIBBEAN
: sl
= "GD"; break; /* Grenada? */
740 case SUBLANG_ENGLISH_BELIZE
: sl
= "BZ"; break;
741 case SUBLANG_ENGLISH_TRINIDAD
: sl
= "TT"; break;
742 case SUBLANG_ENGLISH_ZIMBABWE
: sl
= "ZW"; break;
743 case SUBLANG_ENGLISH_PHILIPPINES
: sl
= "PH"; break;
744 case SUBLANG_ENGLISH_INDONESIA
: sl
= "ID"; break;
745 case SUBLANG_ENGLISH_HONGKONG
: sl
= "HK"; break;
746 case SUBLANG_ENGLISH_INDIA
: sl
= "IN"; break;
747 case SUBLANG_ENGLISH_MALAYSIA
: sl
= "MY"; break;
748 case SUBLANG_ENGLISH_SINGAPORE
: sl
= "SG"; break;
751 case LANG_ESTONIAN
: l
= "et"; sl
= "EE"; break;
752 case LANG_FAEROESE
: l
= "fo"; sl
= "FO"; break;
753 case LANG_FARSI
: l
= "fa"; sl
= "IR"; break;
754 case LANG_FINNISH
: l
= "fi"; sl
= "FI"; break;
759 case SUBLANG_FRENCH
: sl
= "FR"; break;
760 case SUBLANG_FRENCH_BELGIAN
: sl
= "BE"; break;
761 case SUBLANG_FRENCH_CANADIAN
: sl
= "CA"; break;
762 case SUBLANG_FRENCH_SWISS
: sl
= "CH"; break;
763 case SUBLANG_FRENCH_LUXEMBOURG
: sl
= "LU"; break;
764 case SUBLANG_FRENCH_MONACO
: sl
= "MC"; break;
765 case SUBLANG_FRENCH_WESTINDIES
: break;
766 case SUBLANG_FRENCH_REUNION
: sl
= "RE"; break;
767 case SUBLANG_FRENCH_CONGO
: sl
= "CG"; break;
768 case SUBLANG_FRENCH_SENEGAL
: sl
= "SN"; break;
769 case SUBLANG_FRENCH_CAMEROON
: sl
= "CM"; break;
770 case SUBLANG_FRENCH_COTEDIVOIRE
: sl
= "CI"; break;
771 case SUBLANG_FRENCH_MALI
: sl
= "ML"; break;
772 case SUBLANG_FRENCH_MOROCCO
: sl
= "MA"; break;
773 case SUBLANG_FRENCH_HAITI
: sl
= "HT"; break;
776 case LANG_FRISIAN
: l
= "fy"; sl
="NL"; break;
777 case LANG_FULFULDE
: l
= "ful"; sl
= "NG"; break;
781 case 0x01: /* SCOTTISH */ l
= "gd"; sl
= "GB"; break;
782 case 0x02: /* IRISH */ l
= "ga"; sl
= "IE"; break;
785 case LANG_GALICIAN
: l
= "gl"; sl
= "ES"; break;
786 case LANG_GEORGIAN
: l
= "ka"; sl
= "GE"; break;
791 case SUBLANG_GERMAN
: sl
= "DE"; break;
792 case SUBLANG_GERMAN_SWISS
: sl
= "CH"; break;
793 case SUBLANG_GERMAN_AUSTRIAN
: sl
= "AT"; break;
794 case SUBLANG_GERMAN_LUXEMBOURG
: sl
= "LU"; break;
795 case SUBLANG_GERMAN_LIECHTENSTEIN
: sl
= "LI"; break;
798 case LANG_GREEK
: l
= "el"; sl
= "GR"; break;
799 case LANG_GUARANI
: l
= "gn"; sl
= "PY"; break;
800 case LANG_GUJARATI
: l
= "gu"; sl
= "IN"; break;
801 case LANG_HAUSA
: l
= "ha"; sl
= "NG"; break;
803 /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
804 * or Hawaii Creole English ("cpe_US", 600000 speakers)?
809 case LANG_HEBREW
: l
= "he"; sl
= "IL"; break;
810 case LANG_HINDI
: l
= "hi"; sl
= "IN"; break;
811 case LANG_HUNGARIAN
: l
= "hu"; sl
= "HU"; break;
812 case LANG_IBIBIO
: l
= "nic"; sl
= "NG"; break;
813 case LANG_ICELANDIC
: l
= "is"; sl
= "IS"; break;
814 case LANG_IGBO
: l
= "ibo"; sl
= "NG"; break;
815 case LANG_INDONESIAN
: l
= "id"; sl
= "ID"; break;
816 case LANG_INUKTITUT
: l
= "iu"; sl
= "CA"; break;
821 case SUBLANG_ITALIAN
: sl
= "IT"; break;
822 case SUBLANG_ITALIAN_SWISS
: sl
= "CH"; break;
825 case LANG_JAPANESE
: l
= "ja"; sl
= "JP"; break;
826 case LANG_KANNADA
: l
= "kn"; sl
= "IN"; break;
827 case LANG_KANURI
: l
= "kau"; sl
= "NG"; break;
832 case SUBLANG_DEFAULT
: sl
= "PK"; break;
833 case SUBLANG_KASHMIRI_INDIA
: sl
= "IN"; break;
836 case LANG_KAZAK
: l
= "kk"; sl
= "KZ"; break;
838 /* FIXME: Adjust this when such locales appear on Unix. */
842 case LANG_KOREAN
: l
= "ko"; sl
= "KR"; break;
843 case LANG_KYRGYZ
: l
= "ky"; sl
= "KG"; break;
844 case LANG_LAO
: l
= "lo"; sl
= "LA"; break;
845 case LANG_LATIN
: l
= "la"; sl
= "VA"; break;
846 case LANG_LATVIAN
: l
= "lv"; sl
= "LV"; break;
847 case LANG_LITHUANIAN
: l
= "lt"; sl
= "LT"; break;
848 case LANG_MACEDONIAN
: l
= "mk"; sl
= "MK"; break;
853 case SUBLANG_MALAY_MALAYSIA
: sl
= "MY"; break;
854 case SUBLANG_MALAY_BRUNEI_DARUSSALAM
: sl
= "BN"; break;
857 case LANG_MALAYALAM
: l
= "ml"; sl
= "IN"; break;
859 /* FIXME: Adjust this when such locales appear on Unix. */
863 case LANG_MARATHI
: l
= "mr"; sl
= "IN"; break;
865 /* Ambiguous: could be "mn_CN" or "mn_MN". */
872 case SUBLANG_DEFAULT
: sl
= "NP"; break;
873 case SUBLANG_NEPALI_INDIA
: sl
= "IN"; break;
880 case SUBLANG_NORWEGIAN_BOKMAL
: sl
= "NO"; break;
881 case SUBLANG_NORWEGIAN_NYNORSK
: l
= "nn"; sl
= "NO"; break;
884 case LANG_ORIYA
: l
= "or"; sl
= "IN"; break;
885 case LANG_OROMO
: l
= "om"; sl
= "ET"; break;
886 case LANG_PAPIAMENTU
: l
= "pap"; sl
= "AN"; break;
888 /* Ambiguous: could be "ps_PK" or "ps_AF". */
891 case LANG_POLISH
: l
= "pl"; sl
= "PL"; break;
892 case LANG_PORTUGUESE
:
896 case SUBLANG_PORTUGUESE
: sl
= "PT"; break;
897 case SUBLANG_PORTUGUESE_BRAZILIAN
: sl
= "BR"; break;
904 case SUBLANG_PUNJABI_INDIA
: sl
= "IN"; break; /* Gurmukhi script */
905 case SUBLANG_PUNJABI_PAKISTAN
: sl
= "PK"; break; /* Arabic script */
908 case LANG_RHAETO_ROMANCE
: l
= "rm"; sl
= "CH"; break;
913 case SUBLANG_ROMANIAN_ROMANIA
: sl
= "RO"; break;
914 case SUBLANG_ROMANIAN_MOLDOVA
: sl
= "MD"; break;
918 l
= "ru";/* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */
920 case LANG_SAAMI
: /* actually Northern Sami */ l
= "se"; sl
= "NO"; break;
921 case LANG_SANSKRIT
: l
= "sa"; sl
= "IN"; break;
922 case LANG_SINDHI
: l
= "sd";
925 case SUBLANG_SINDHI_INDIA
: sl
= "IN"; break;
926 case SUBLANG_SINDHI_PAKISTAN
: sl
= "PK"; break;
929 case LANG_SINHALESE
: l
= "si"; sl
= "LK"; break;
930 case LANG_SLOVAK
: l
= "sk"; sl
= "SK"; break;
931 case LANG_SLOVENIAN
: l
= "sl"; sl
= "SI"; break;
932 case LANG_SOMALI
: l
= "so"; sl
= "SO"; break;
934 /* FIXME: Adjust this when such locales appear on Unix. */
942 case SUBLANG_SPANISH
: sl
= "ES"; break;
943 case SUBLANG_SPANISH_MEXICAN
: sl
= "MX"; break;
944 case SUBLANG_SPANISH_MODERN
:
945 sl
= "ES@modern"; break; /* not seen on Unix */
946 case SUBLANG_SPANISH_GUATEMALA
: sl
= "GT"; break;
947 case SUBLANG_SPANISH_COSTA_RICA
: sl
= "CR"; break;
948 case SUBLANG_SPANISH_PANAMA
: sl
= "PA"; break;
949 case SUBLANG_SPANISH_DOMINICAN_REPUBLIC
: sl
= "DO"; break;
950 case SUBLANG_SPANISH_VENEZUELA
: sl
= "VE"; break;
951 case SUBLANG_SPANISH_COLOMBIA
: sl
= "CO"; break;
952 case SUBLANG_SPANISH_PERU
: sl
= "PE"; break;
953 case SUBLANG_SPANISH_ARGENTINA
: sl
= "AR"; break;
954 case SUBLANG_SPANISH_ECUADOR
: sl
= "EC"; break;
955 case SUBLANG_SPANISH_CHILE
: sl
= "CL"; break;
956 case SUBLANG_SPANISH_URUGUAY
: sl
= "UY"; break;
957 case SUBLANG_SPANISH_PARAGUAY
: sl
= "PY"; break;
958 case SUBLANG_SPANISH_BOLIVIA
: sl
= "BO"; break;
959 case SUBLANG_SPANISH_EL_SALVADOR
: sl
= "SV"; break;
960 case SUBLANG_SPANISH_HONDURAS
: sl
= "HN"; break;
961 case SUBLANG_SPANISH_NICARAGUA
: sl
= "NI"; break;
962 case SUBLANG_SPANISH_PUERTO_RICO
: sl
= "PR"; break;
965 case LANG_SUTU
: l
= "bnt"; sl
= "TZ"; break; /* or "st_LS" or "nso_ZA"? */
966 case LANG_SWAHILI
: l
= "sw"; sl
= "KE"; break;
971 case SUBLANG_DEFAULT
: sl
= "SE"; break;
972 case SUBLANG_SWEDISH_FINLAND
: sl
= "FI"; break;
975 case LANG_SYRIAC
: l
= "syr"; sl
= "TR"; break; /* An extinct language. */
976 case LANG_TAGALOG
: l
= "tl"; sl
= "PH"; break;
977 case LANG_TAJIK
: l
= "tg"; sl
= "TJ"; break;
979 l
= "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
981 case LANG_TATAR
: l
= "tt"; sl
= "RU"; break;
982 case LANG_TELUGU
: l
= "te"; sl
= "IN"; break;
983 case LANG_THAI
: l
= "th"; sl
= "TH"; break;
984 case LANG_TIBETAN
: l
= "bo"; sl
= "CN"; break;
989 case SUBLANG_TIGRINYA_ETHIOPIA
: sl
= "ET"; break;
990 case SUBLANG_TIGRINYA_ERITREA
: sl
= "ER"; break;
993 case LANG_TSONGA
: l
= "ts"; sl
= "ZA"; break;
994 case LANG_TSWANA
: l
= "tn"; sl
= "BW"; break;
995 case LANG_TURKISH
: l
= "tr"; sl
= "TR"; break;
996 case LANG_TURKMEN
: l
= "tk"; sl
= "TM"; break;
997 case LANG_UKRAINIAN
: l
= "uk"; sl
= "UA"; break;
1002 case SUBLANG_URDU_PAKISTAN
: sl
= "PK"; break;
1003 case SUBLANG_URDU_INDIA
: sl
= "IN"; break;
1010 case SUBLANG_UZBEK_LATIN
: sl
= "UZ"; break;
1011 case SUBLANG_UZBEK_CYRILLIC
: sl
= "UZ@cyrillic"; break;
1015 /* FIXME: It's not clear whether Venda has the ISO 639-2 two-letter code
1017 http://www.loc.gov/standards/iso639-2/englangn.html has it, but
1018 http://lcweb.loc.gov/standards/iso639-2/codechanges.html doesn't, */
1019 l
= "ven"; /* or "ve"? */
1022 case LANG_VIETNAMESE
: l
= "vi"; sl
= "VN"; break;
1023 case LANG_WELSH
: l
= "cy"; sl
= "GB"; break;
1024 case LANG_XHOSA
: l
= "xh"; sl
= "ZA"; break;
1025 case LANG_YI
: l
= "sit"; sl
= "CN"; break;
1026 case LANG_YIDDISH
: l
= "yi"; sl
= "IL"; break;
1027 case LANG_YORUBA
: l
= "yo"; sl
= "NG"; break;
1028 case LANG_ZULU
: l
= "zu"; sl
= "ZA"; break;
1038 return g_strdup (bfr
);
1042 * g_win32_error_message:
1043 * @error: error code.
1045 * Translate a Win32 error code (as returned by GetLastError()) into
1046 * the corresponding message. The message is either language neutral,
1047 * or in the thread's language, or the user's language, the system's
1048 * language, or US English (see docs for FormatMessage()). The
1049 * returned string is in UTF-8. It should be deallocated with
1052 * Returns: newly-allocated error message
1055 g_win32_error_message (gint error
)
1058 wchar_t *msg
= NULL
;
1061 FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER
1062 |FORMAT_MESSAGE_IGNORE_INSERTS
1063 |FORMAT_MESSAGE_FROM_SYSTEM
,
1065 (LPWSTR
) &msg
, 0, NULL
);
1068 nchars
= wcslen (msg
);
1070 if (nchars
> 2 && msg
[nchars
-1] == '\n' && msg
[nchars
-2] == '\r')
1071 msg
[nchars
-2] = '\0';
1073 retval
= g_utf16_to_utf8 (msg
, -1, NULL
, NULL
, NULL
);
1078 retval
= g_strdup ("");
1084 get_package_directory_from_module (gchar
*module_name
)
1086 static GHashTable
*module_dirs
= NULL
;
1087 G_LOCK_DEFINE_STATIC (module_dirs
);
1088 HMODULE hmodule
= NULL
;
1092 wchar_t wc_fn
[MAX_PATH
];
1094 G_LOCK (module_dirs
);
1096 if (module_dirs
== NULL
)
1097 module_dirs
= g_hash_table_new (g_str_hash
, g_str_equal
);
1099 result
= g_hash_table_lookup (module_dirs
, module_name
? module_name
: "");
1103 G_UNLOCK (module_dirs
);
1104 return g_strdup (result
);
1109 wchar_t *wc_module_name
= g_utf8_to_utf16 (module_name
, -1, NULL
, NULL
, NULL
);
1110 hmodule
= GetModuleHandleW (wc_module_name
);
1111 g_free (wc_module_name
);
1117 if (!GetModuleFileNameW (hmodule
, wc_fn
, MAX_PATH
))
1119 G_UNLOCK (module_dirs
);
1122 fn
= g_utf16_to_utf8 (wc_fn
, -1, NULL
, NULL
, NULL
);
1124 if ((p
= strrchr (fn
, G_DIR_SEPARATOR
)) != NULL
)
1127 p
= strrchr (fn
, G_DIR_SEPARATOR
);
1128 if (p
&& (g_ascii_strcasecmp (p
+ 1, "bin") == 0 ||
1129 g_ascii_strcasecmp (p
+ 1, "lib") == 0))
1132 #ifdef G_WITH_CYGWIN
1133 /* In Cygwin we need to have POSIX paths */
1135 gchar tmp
[MAX_PATH
];
1137 cygwin_conv_to_posix_path(fn
, tmp
);
1143 g_hash_table_insert (module_dirs
, module_name
? g_strdup (module_name
) : "", fn
);
1145 G_UNLOCK (module_dirs
);
1147 return g_strdup (fn
);
1151 * g_win32_get_package_installation_directory:
1152 * @package: An identifier for a software package, or %NULL, in UTF-8
1153 * @dll_name: The name of a DLL that a package provides, or %NULL, in UTF-8
1155 * Try to determine the installation directory for a software package.
1156 * Typically used by GNU software packages.
1158 * @package should be a short identifier for the package. Typically it
1159 * is the same identifier as used for
1160 * <literal>GETTEXT_PACKAGE</literal> in software configured according
1161 * to GNU standards. The function first looks in the Windows Registry
1162 * for the value <literal>#InstallationDirectory</literal> in the key
1163 * <literal>#HKLM\Software\@package</literal>, and if that value
1164 * exists and is a string, returns that.
1166 * If @package is %NULL, or the above value isn't found in the
1167 * Registry, but @dll_name is non-%NULL, it should name a DLL loaded
1168 * into the current process. Typically that would be the name of the
1169 * DLL calling this function, looking for its installation
1170 * directory. The function then asks Windows what directory that DLL
1171 * was loaded from. If that directory's last component is "bin" or
1172 * "lib", the parent directory is returned, otherwise the directory
1173 * itself. If that DLL isn't loaded, the function proceeds as if
1174 * @dll_name was %NULL.
1176 * If both @package and @dll_name are %NULL, the directory from where
1177 * the main executable of the process was loaded is used instead in
1178 * the same way as above.
1180 * Returns: a string containing the installation directory for
1181 * @package. The string is in the GLib file name encoding, i.e. UTF-8
1182 * on Windows. The return value should be freed with g_free() when not
1183 * needed any longer.
1187 g_win32_get_package_installation_directory (gchar
*package
,
1190 static GHashTable
*package_dirs
= NULL
;
1191 G_LOCK_DEFINE_STATIC (package_dirs
);
1192 gchar
*result
= NULL
;
1195 HKEY reg_key
= NULL
;
1199 if (package
!= NULL
)
1201 G_LOCK (package_dirs
);
1203 if (package_dirs
== NULL
)
1204 package_dirs
= g_hash_table_new (g_str_hash
, g_str_equal
);
1206 result
= g_hash_table_lookup (package_dirs
, package
);
1208 if (result
&& result
[0])
1210 G_UNLOCK (package_dirs
);
1211 return g_strdup (result
);
1214 key
= g_strconcat ("Software\\", package
, NULL
);
1218 wc_key
= g_utf8_to_utf16 (key
, -1, NULL
, NULL
, NULL
);
1219 if (((RegOpenKeyExW (HKEY_CURRENT_USER
, wc_key
, 0,
1220 KEY_QUERY_VALUE
, ®_key
) == ERROR_SUCCESS
1221 && RegQueryValueExW (reg_key
, L
"InstallationDirectory", 0,
1222 &type
, NULL
, &nbytes
) == ERROR_SUCCESS
)
1224 (RegOpenKeyExW (HKEY_LOCAL_MACHINE
, wc_key
, 0,
1225 KEY_QUERY_VALUE
, ®_key
) == ERROR_SUCCESS
1226 && RegQueryValueExW (reg_key
, L
"InstallationDirectory", 0,
1227 &type
, NULL
, &nbytes
) == ERROR_SUCCESS
))
1230 wchar_t *wc_temp
= g_new (wchar_t, (nbytes
+1)/2 + 1);
1231 RegQueryValueExW (reg_key
, L
"InstallationDirectory", 0,
1232 &type
, (LPBYTE
) wc_temp
, &nbytes
);
1233 wc_temp
[nbytes
/2] = '\0';
1234 result
= g_utf16_to_utf8 (wc_temp
, -1, NULL
, NULL
, NULL
);
1239 if (reg_key
!= NULL
)
1240 RegCloseKey (reg_key
);
1246 g_hash_table_insert (package_dirs
, g_strdup (package
), result
);
1247 G_UNLOCK (package_dirs
);
1248 return g_strdup (result
);
1250 G_UNLOCK (package_dirs
);
1253 if (dll_name
!= NULL
)
1254 result
= get_package_directory_from_module (dll_name
);
1257 result
= get_package_directory_from_module (NULL
);
1262 #undef g_win32_get_package_installation_directory
1264 /* DLL ABI binary compatibility version that uses system codepage file names */
1267 g_win32_get_package_installation_directory (gchar
*package
,
1270 gchar
*utf8_package
= NULL
, *utf8_dll_name
= NULL
;
1271 gchar
*utf8_retval
, *retval
;
1273 if (package
!= NULL
)
1274 utf8_package
= g_locale_to_utf8 (package
, -1, NULL
, NULL
, NULL
);
1276 if (dll_name
!= NULL
)
1277 utf8_dll_name
= g_locale_to_utf8 (dll_name
, -1, NULL
, NULL
, NULL
);
1280 g_win32_get_package_installation_directory_utf8 (utf8_package
,
1283 retval
= g_locale_from_utf8 (utf8_retval
, -1, NULL
, NULL
, NULL
);
1285 g_free (utf8_package
);
1286 g_free (utf8_dll_name
);
1287 g_free (utf8_retval
);
1293 * g_win32_get_package_installation_subdirectory:
1294 * @package: An identifier for a software package, in UTF-8, or %NULL
1295 * @dll_name: The name of a DLL that a package provides, in UTF-8, or %NULL
1296 * @subdir: A subdirectory of the package installation directory, also in UTF-8
1298 * Returns a newly-allocated string containing the path of the
1299 * subdirectory @subdir in the return value from calling
1300 * g_win32_get_package_installation_directory() with the @package and
1301 * @dll_name parameters.
1303 * Returns: a string containing the complete path to @subdir inside
1304 * the installation directory of @package. The returned string is in
1305 * the GLib file name encoding, i.e. UTF-8 on Windows. The return
1306 * value should be freed with g_free() when no longer needed.
1310 g_win32_get_package_installation_subdirectory (gchar
*package
,
1317 prefix
= g_win32_get_package_installation_directory_utf8 (package
, dll_name
);
1319 dirname
= g_build_filename (prefix
, subdir
, NULL
);
1325 #undef g_win32_get_package_installation_subdirectory
1327 /* DLL ABI binary compatibility version that uses system codepage file names */
1330 g_win32_get_package_installation_subdirectory (gchar
*package
,
1337 prefix
= g_win32_get_package_installation_directory (package
, dll_name
);
1339 dirname
= g_build_filename (prefix
, subdir
, NULL
);
1345 static guint windows_version
;
1348 g_win32_windows_version_init (void)
1350 static gboolean beenhere
= FALSE
;
1355 windows_version
= GetVersion ();
1357 if (windows_version
& 0x80000000)
1358 g_error ("This version of GLib requires NT-based Windows.");
1363 _g_win32_thread_init (void)
1365 g_win32_windows_version_init ();
1369 * g_win32_get_windows_version:
1371 * Returns version information for the Windows operating system the
1372 * code is running on. See MSDN documentation for the GetVersion()
1373 * function. To summarize, the most significant bit is one on Win9x,
1374 * and zero on NT-based systems. Since version 2.14, GLib works only
1375 * on NT-based systems, so checking whether your are running on Win9x
1376 * in your own software is moot. The least significant byte is 4 on
1377 * Windows NT 4, and 5 on Windows XP. Software that needs really
1378 * detailled version and feature information should use Win32 API like
1379 * GetVersionEx() and VerifyVersionInfo().
1381 * Returns: The version information.
1386 g_win32_get_windows_version (void)
1388 g_win32_windows_version_init ();
1390 return windows_version
;
1394 * g_win32_locale_filename_from_utf8:
1395 * @utf8filename: a UTF-8 encoded filename.
1397 * Converts a filename from UTF-8 to the system codepage.
1399 * On NT-based Windows, on NTFS file systems, file names are in
1400 * Unicode. It is quite possible that Unicode file names contain
1401 * characters not representable in the system codepage. (For instance,
1402 * Greek or Cyrillic characters on Western European or US Windows
1403 * installations, or various less common CJK characters on CJK Windows
1406 * In such a case, and if the filename refers to an existing file, and
1407 * the file system stores alternate short (8.3) names for directory
1408 * entries, the short form of the filename is returned. Note that the
1409 * "short" name might in fact be longer than the Unicode name if the
1410 * Unicode name has very short pathname components containing
1411 * non-ASCII characters. If no system codepage name for the file is
1412 * possible, %NULL is returned.
1414 * The return value is dynamically allocated and should be freed with
1415 * g_free() when no longer needed.
1417 * Return value: The converted filename, or %NULL on conversion
1418 * failure and lack of short names.
1423 g_win32_locale_filename_from_utf8 (const gchar
*utf8filename
)
1425 gchar
*retval
= g_locale_from_utf8 (utf8filename
, -1, NULL
, NULL
, NULL
);
1429 /* Conversion failed, so convert to wide chars, check if there
1430 * is a 8.3 version, and use that.
1432 wchar_t *wname
= g_utf8_to_utf16 (utf8filename
, -1, NULL
, NULL
, NULL
);
1435 wchar_t wshortname
[MAX_PATH
+ 1];
1436 if (GetShortPathNameW (wname
, wshortname
, G_N_ELEMENTS (wshortname
)))
1438 gchar
*tem
= g_utf16_to_utf8 (wshortname
, -1, NULL
, NULL
, NULL
);
1439 retval
= g_locale_from_utf8 (tem
, -1, NULL
, NULL
, NULL
);
1448 #define __G_WIN32_C__
1449 #include "galiasdef.c"