This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_gv_init_pvn() must handle a stash holding the value -1
[perl5.git] / t / loc_tools.pl
1 # Common tools for test files to find the locales which exist on the
2 # system.  Caller should have verified that this isn't miniperl before calling
3 # the functions.
4
5 # Note that it's okay that some languages have their native names
6 # capitalized here even though that's not "right".  They are lowercased
7 # anyway later during the scanning process (and besides, some clueless
8 # vendor might have them capitalized erroneously anyway).
9
10 # Functions whose names begin with underscore are internal helper functions
11 # for this file, and are not to be used by outside callers.
12
13 use Config;
14 use strict;
15 use warnings;
16 use feature 'state';
17
18 eval { require POSIX; import POSIX 'locale_h'; };
19 my $has_locale_h = ! $@;
20
21 my @known_categories = ( qw(LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY
22                             LC_NUMERIC LC_TIME LC_ADDRESS LC_IDENTIFICATION
23                             LC_MEASUREMENT LC_PAPER LC_TELEPHONE LC_SYNTAX
24                             LC_TOD));
25 my @platform_categories;
26
27 sub is_category_valid($) {
28     my $cat_name = shift =~ s/^LC_//r;
29
30     # Recognize Configure option to exclude a category
31     return $Config{ccflags} !~ /\bD?NO_LOCALE_$cat_name\b/;
32 }
33
34 # LC_ALL can be -1 on some platforms.  And, in fact the implementors could
35 # legally use any integer to represent any category.  But it makes the most
36 # sense for them to have used small integers.  Below, we create new locale
37 # numbers for ones missing from this machine.  We make them very negative,
38 # hopefully more negative than anything likely to be a valid category on the
39 # platform, but also below is a check to be sure that our guess is valid.
40 my $max_bad_category_number = -1000000;
41
42 # Initialize this hash so that it looks like e.g.,
43 #   6 => 'CTYPE',
44 # where 6 is the value of &POSIX::LC_CTYPE
45 my %category_name;
46 my %category_number;
47 if ($has_locale_h) {
48     my $number_for_missing_category = $max_bad_category_number;
49     foreach my $name (@known_categories) {
50         my $number = eval "&POSIX::$name";
51         if ($@) {
52             # Use a negative number (smaller than any legitimate category
53             # number) if the platform doesn't support this category, so we
54             # have an entry for all the ones that might be specified in calls
55             # to us.
56             $number = $number_for_missing_category--;
57         }
58         elsif (   $number !~ / ^ -? \d+ $ /x
59                || $number <=  $max_bad_category_number)
60         {
61             # We think this should be an int.  And it has to be larger than
62             # any of our synthetic numbers.
63             die "Unexpected locale category number '$number' for $name"
64         }
65         else {
66             push @platform_categories, $name;
67         }
68
69         $name =~ s/LC_//;
70         $category_name{$number} = "$name";
71         $category_number{$name} = $number;
72     }
73 }
74
75 sub _my_diag($) {
76     my $message = shift;
77     if (defined &main::diag) {
78         diag($message);
79     }
80     else {
81         local($\, $", $,) = (undef, ' ', '');
82         print STDERR $message, "\n";
83     }
84 }
85
86 sub _my_fail($) {
87     my $message = shift;
88     if (defined &main::fail) {
89         fail($message);
90     }
91     else {
92         local($\, $", $,) = (undef, ' ', '');
93         print "not ok 0 $message\n";
94     }
95 }
96
97 sub _trylocale ($$$$) { # For use only by other functions in this file!
98
99     # Adds the locale given by the first parameter to the list given by the
100     # 3rd iff the platform supports the locale in each of the category numbers
101     # given by the 2nd parameter, which is either a single category or a
102     # reference to a list of categories.
103     #
104     # The 4th parameter is true if to accept locales that aren't apparently
105     # fully compatible with Perl.
106
107     my $locale = shift;
108     my $categories = shift;
109     my $list = shift;
110     my $allow_incompatible = shift;
111
112     return if ! $locale || grep { $locale eq $_ } @$list;
113
114     # This is a toy (pig latin) locale that is not fully implemented on some
115     # systems
116     return if $locale =~ / ^ pig $ /ix;
117
118     # Certain platforms have a crippled locale system in which setlocale
119     # returns success for just about any possible locale name, but if anything
120     # actually happens as a result of the call, it is that the underlying
121     # locale is set to a system default, likely C or C.UTF-8.  We can't test
122     # such systems fully, but we shouldn't disable the user from using
123     # locales, as it may work out for them (or not).
124     return if    defined $Config{d_setlocale_accepts_any_locale_name}
125               && $locale !~ / ^ (?: C | POSIX | C\.UTF-8 ) $/ix;
126
127     $categories = [ $categories ] unless ref $categories;
128
129     my $badutf8 = 0;
130     my $plays_well = 1;
131
132     use warnings 'locale';
133
134     local $SIG{__WARN__} = sub {
135         $badutf8 = 1 if grep { /Malformed UTF-8/ } @_;
136         $plays_well = 0 if grep {
137                     /Locale .* may not work well(?#
138                    )|The Perl program will use the expected meanings/i
139             } @_;
140     };
141
142     # Incompatible locales aren't warned about unless using locales.
143     use locale;
144
145     # Sort the input so CTYPE is first, COLLATE comes after all but ALL.  This
146     # is because locale.c detects bad locales only with CTYPE, and COLLATE on
147     # some platforms can core dump if it is a bad locale.
148     my @sorted;
149     my $has_ctype = 0;
150     my $has_all = 0;
151     my $has_collate = 0;
152     foreach my $category (@$categories) {
153         die "category '$category' must instead be a number"
154                                             unless $category =~ / ^ -? \d+ $ /x;
155         if ($category_name{$category} eq 'CTYPE') {
156             $has_ctype = 1;
157         }
158         elsif ($category_name{$category} eq 'ALL') {
159             $has_all = 1;
160         }
161         elsif ($category_name{$category} eq 'COLLATE') {
162             $has_collate = 1;
163         }
164         else {
165             push @sorted, $category unless grep { $_ == $category } @sorted;
166         }
167     }
168     push @sorted, $category_number{'COLLATE'} if $has_collate;
169     push @sorted, $category_number{'ALL'} if $has_all;
170     unshift @sorted, $category_number{'CTYPE'} if $has_ctype || ! $allow_incompatible;
171
172     foreach my $category (@sorted) {
173         return unless setlocale($category, $locale);
174         last if $badutf8 || ! $plays_well;
175     }
176
177     if ($badutf8) {
178         _my_fail("Verify locale name doesn't contain malformed utf8");
179         return;
180     }
181     push @$list, $locale if $plays_well || $allow_incompatible;
182 }
183
184 sub _decode_encodings { # For use only by other functions in this file!
185     my @enc;
186
187     foreach (split(/ /, shift)) {
188         if (/^(\d+)$/) {
189             push @enc, "ISO8859-$1";
190             push @enc, "iso8859$1";     # HP
191             if ($1 eq '1') {
192                  push @enc, "roman8";   # HP
193             }
194             push @enc, $_;
195             push @enc, "$_.UTF-8";
196             push @enc, "$_.65001"; # Windows UTF-8
197             push @enc, "$_.ACP"; # Windows ANSI code page
198             push @enc, "$_.OCP"; # Windows OEM code page
199             push @enc, "$_.1252"; # Windows
200         }
201     }
202     if ($^O eq 'os390') {
203         push @enc, qw(IBM-037 IBM-819 IBM-1047);
204     }
205     push @enc, "UTF-8";
206     push @enc, "65001"; # Windows UTF-8
207
208     return @enc;
209 }
210
211 sub valid_locale_categories() {
212     # Returns a list of the locale categories (expressed as strings, like
213     # "LC_ALL) known to this program that are available on this platform.
214
215     return grep { is_category_valid($_) } @platform_categories;
216 }
217
218 sub locales_enabled(;$) {
219     # If no parameter is specified, the function returns 1 if there is any
220     # "safe" locale handling available to the caller; otherwise 0.  Safeness
221     # is defined here as the caller operating in the main thread of a program,
222     # or if threaded locales are safe on the platform and Configured to be
223     # used.  This sub is used for testing purposes, and for those, this
224     # definition of safety is sufficient, and necessary to get some tests to
225     # run on certain configurations on certain platforms.  But beware that the
226     # main thread can change the locale of any subthreads unless
227     # ${^SAFE_LOCALES} is non-zero.
228     #
229     # Use the optional parameter to discover if a particular category or
230     # categories are available on the system.  1 is returned if the global
231     # criteria described in the previous paragraph are true, AND if all the
232     # specified categories are available on the platform and Configured to be
233     # used.  Otherwise 0 is returned.  The parameter is either a single POSIX
234     # locale category or a reference to a list of them.  Each category must be
235     # its name as a string, like 'LC_TIME' (the initial 'LC_' is optional), or
236     # the number this platform uses to signify the category (e.g.,
237     # 'locales_enabled(&POSIX::LC_CTYPE)'
238     #
239     # When the function returns 1 and a parameter was specified as a list
240     # reference, the reference will be altered on return to point to an
241     # equivalent list such that  the categories are numeric instead of strings
242     # and sorted to meet the input expectations of _trylocale().
243     #
244     # It is a fatal error to call this with something that isn't a known
245     # category to this file.  If this happens, look first for a typo, and
246     # second if you are using a category unknown to Perl.  In the latter case
247     # a bug report should be submitted.
248
249     # khw cargo-culted the '?' in the pattern on the next line.
250     return 0 if $Config{ccflags} =~ /\bD?NO_LOCALE\b/;
251
252     # If we can't load the POSIX XS module, we can't have locales even if they
253     # normally would be available
254     return 0 if ! defined &DynaLoader::boot_DynaLoader;
255
256     # Don't test locales where they aren't safe.  On systems with unsafe
257     # threads, for the purposes of testing, we consider the main thread safe,
258     # and all other threads unsafe.
259     if (! ${^SAFE_LOCALES}) {
260         require threads;
261         return 0 if threads->tid() != 0;
262     }
263
264     # If no setlocale, we need the POSIX 2008 alternatives
265     if (! $Config{d_setlocale}) {
266         return 0 if $Config{ccflags} =~ /\bD?NO_POSIX_2008_LOCALE\b/;
267         return 0 unless $Config{d_newlocale};
268         return 0 unless $Config{d_uselocale};
269         return 0 unless $Config{d_duplocale};
270         return 0 unless $Config{d_freelocale};
271     }
272
273     # Done with the global possibilities.  Now check if any passed in category
274     # is disabled.
275
276     my $categories_ref = $_[0];
277     my $return_categories_numbers = 0;
278     my @categories_numbers;
279     my $has_LC_ALL = 0;
280     my $has_LC_COLLATE = 0;
281
282     if (defined $categories_ref) {
283         my @local_categories_copy;
284
285         my $reftype = ref $categories_ref;
286         if ($reftype eq 'ARRAY') {
287             @local_categories_copy = @$categories_ref;
288             $return_categories_numbers = 1;
289         }
290         elsif ($reftype ne "") {
291             die "Parameter to locales_enabled() must be an ARRAY;"
292               . " instead you used a $reftype";
293         }
294         else {  # Single category passed in
295             @local_categories_copy = $categories_ref;
296         }
297
298         for my $category_name_or_number (@local_categories_copy) {
299             my $name;
300             my $number;
301             if ($category_name_or_number =~ / ^ -? \d+ $ /x) {
302                 $number = $category_name_or_number;
303                 die "Invalid locale category number '$number'"
304                     unless grep { $number == $_ } keys %category_name;
305                 $name = $category_name{$number};
306             }
307             else {
308                 $name = $category_name_or_number;
309                 $name =~ s/ ^ LC_ //x;
310                 foreach my $trial (keys %category_name) {
311                     if ($category_name{$trial} eq $name) {
312                         $number = $trial;
313                         last;
314                     }
315                 }
316                 die "Invalid locale category name '$name'"
317                     unless defined $number;
318             }
319
320             return 0 if     $number <= $max_bad_category_number
321                        || ! is_category_valid($name);
322
323
324             eval "defined &POSIX::LC_$name";
325             return 0 if $@;
326
327             if ($return_categories_numbers) {
328                 if ($name eq 'CTYPE') {
329                     unshift @categories_numbers, $number;   # Always first
330                 }
331                 elsif ($name eq 'ALL') {
332                     $has_LC_ALL = 1;
333                 }
334                 elsif ($name eq 'COLLATE') {
335                     $has_LC_COLLATE = 1;
336                 }
337                 else {
338                     push @categories_numbers, $number;
339                 }
340             }
341         }
342     }
343
344     if ($return_categories_numbers) {
345
346         # COLLATE comes after all other locales except ALL, which comes last
347         if ($has_LC_COLLATE) {
348             push @categories_numbers, $category_number{'COLLATE'};
349         }
350         if ($has_LC_ALL) {
351             push @categories_numbers, $category_number{'ALL'};
352         }
353
354         @$categories_ref = @categories_numbers;
355     }
356
357     return 1;
358 }
359
360
361 sub find_locales ($;$) {
362
363     # Returns an array of all the locales we found on the system.  If the
364     # optional 2nd parameter is non-zero, the list includes all found locales;
365     # otherwise it is restricted to those locales that play well with Perl, as
366     # far as we can easily determine.
367     #
368     # The first parameter is either a single locale category or a reference to
369     # a list of categories to find valid locales for it (or in the case of
370     # multiple) for all of them.  Each category can be a name (like 'LC_ALL'
371     # or simply 'ALL') or the C enum value for the category.
372
373     my $input_categories = shift;
374     my $allow_incompatible = shift // 0;
375
376     my @categories = (ref $input_categories) ? $input_categories->@* : $input_categories;
377     return unless locales_enabled(\@categories);
378
379     # Note, the subroutine call above converts the $categories into a form
380     # suitable for _trylocale().
381
382     # Visual C's CRT goes silly on strings of the form "en_US.ISO8859-1"
383     # and mingw32 uses said silly CRT
384     # This doesn't seem to be an issue any more, at least on Windows XP,
385     # so re-enable the tests for Windows XP onwards.
386     my $winxp = ($^O eq 'MSWin32' && defined &Win32::GetOSVersion &&
387                     join('.', (Win32::GetOSVersion())[1..2]) >= 5.1);
388     return if (($^O eq 'MSWin32' && !$winxp)
389                 && $Config{cc} =~ /^(cl|gcc|g\+\+|ici)/i);
390
391     my @Locale;
392     _trylocale("C", \@categories, \@Locale, $allow_incompatible);
393     _trylocale("POSIX", \@categories, \@Locale, $allow_incompatible);
394
395     if ($Config{d_has_C_UTF8} && $Config{d_has_C_UTF8} eq 'true') {
396         _trylocale("C.UTF-8", \@categories, \@Locale, $allow_incompatible);
397     }
398
399     # There's no point in looking at anything more if we know that setlocale
400     # will return success on any garbage or non-garbage name.
401     return sort @Locale if defined $Config{d_setlocale_accepts_any_locale_name};
402
403     foreach (1..16) {
404         _trylocale("ISO8859-$_", \@categories, \@Locale, $allow_incompatible);
405         _trylocale("iso8859$_", \@categories, \@Locale, $allow_incompatible);
406         _trylocale("iso8859-$_", \@categories, \@Locale, $allow_incompatible);
407         _trylocale("iso_8859_$_", \@categories, \@Locale, $allow_incompatible);
408         _trylocale("isolatin$_", \@categories, \@Locale, $allow_incompatible);
409         _trylocale("isolatin-$_", \@categories, \@Locale, $allow_incompatible);
410         _trylocale("iso_latin_$_", \@categories, \@Locale, $allow_incompatible);
411     }
412
413     # Sanitize the environment so that we can run the external 'locale'
414     # program without the taint mode getting grumpy.
415
416     # $ENV{PATH} is special in VMS.
417     delete local $ENV{PATH} if $^O ne 'VMS' or $Config{d_setenv};
418
419     # Other subversive stuff.
420     delete local @ENV{qw(IFS CDPATH ENV BASH_ENV)};
421
422     if (-x "/usr/bin/locale"
423         && open(LOCALES, '-|', "/usr/bin/locale -a 2>/dev/null"))
424     {
425         while (<LOCALES>) {
426             # It seems that /usr/bin/locale steadfastly outputs 8 bit data, which
427             # ain't great when we're running this testPERL_UNICODE= so that utf8
428             # locales will cause all IO hadles to default to (assume) utf8
429             next unless utf8::valid($_);
430             chomp;
431             _trylocale($_, \@categories, \@Locale, $allow_incompatible);
432         }
433         close(LOCALES);
434     } elsif ($^O eq 'VMS'
435              && defined($ENV{'SYS$I18N_LOCALE'})
436              && -d 'SYS$I18N_LOCALE')
437     {
438     # The SYS$I18N_LOCALE logical name search list was not present on
439     # VAX VMS V5.5-12, but was on AXP && VAX VMS V6.2 as well as later versions.
440         opendir(LOCALES, "SYS\$I18N_LOCALE:");
441         while ($_ = readdir(LOCALES)) {
442             chomp;
443             _trylocale($_, \@categories, \@Locale, $allow_incompatible);
444         }
445         close(LOCALES);
446     } elsif (($^O eq 'openbsd' || $^O eq 'bitrig' ) && -e '/usr/share/locale') {
447
448         # OpenBSD doesn't have a locale executable, so reading
449         # /usr/share/locale is much easier and faster than the last resort
450         # method.
451
452         opendir(LOCALES, '/usr/share/locale');
453         while ($_ = readdir(LOCALES)) {
454             chomp;
455             _trylocale($_, \@categories, \@Locale, $allow_incompatible);
456         }
457         close(LOCALES);
458     } else { # Final fallback.  Try our list of locales hard-coded here
459
460         # This is going to be slow.
461         my @Data;
462
463         # Locales whose name differs if the utf8 bit is on are stored in these
464         # two files with appropriate encodings.
465         my $data_file = ($^H & 0x08 || (${^OPEN} || "") =~ /:utf8/)
466                         ? _source_location() . "/lib/locale/utf8"
467                         : _source_location() . "/lib/locale/latin1";
468         if (-e $data_file) {
469             @Data = do $data_file;
470         }
471         else {
472             _my_diag(__FILE__ . ":" . __LINE__ . ": '$data_file' doesn't exist");
473         }
474
475         # The rest of the locales are in this file.
476         state @my_data = <DATA>; close DATA if fileno DATA;
477         push @Data, @my_data;
478
479         foreach my $line (@Data) {
480             chomp $line;
481             my ($locale_name, $language_codes, $country_codes, $encodings) =
482                 split /:/, $line;
483             _my_diag(__FILE__ . ":" . __LINE__ . ": Unexpected syntax in '$line'")
484                                                      unless defined $locale_name;
485             my @enc = _decode_encodings($encodings);
486             foreach my $loc (split(/ /, $locale_name)) {
487                 _trylocale($loc, \@categories, \@Locale, $allow_incompatible);
488                 foreach my $enc (@enc) {
489                     _trylocale("$loc.$enc", \@categories, \@Locale,
490                                                             $allow_incompatible);
491                 }
492                 $loc = lc $loc;
493                 foreach my $enc (@enc) {
494                     _trylocale("$loc.$enc", \@categories, \@Locale,
495                                                             $allow_incompatible);
496                 }
497             }
498             foreach my $lang (split(/ /, $language_codes)) {
499                 _trylocale($lang, \@categories, \@Locale, $allow_incompatible);
500                 foreach my $country (split(/ /, $country_codes)) {
501                     my $lc = "${lang}_${country}";
502                     _trylocale($lc, \@categories, \@Locale, $allow_incompatible);
503                     foreach my $enc (@enc) {
504                         _trylocale("$lc.$enc", \@categories, \@Locale,
505                                                             $allow_incompatible);
506                     }
507                     my $lC = "${lang}_\U${country}";
508                     _trylocale($lC, \@categories, \@Locale, $allow_incompatible);
509                     foreach my $enc (@enc) {
510                         _trylocale("$lC.$enc", \@categories, \@Locale,
511                                                             $allow_incompatible);
512                     }
513                 }
514             }
515         }
516     }
517
518     @Locale = sort @Locale;
519
520     return @Locale;
521 }
522
523 sub is_locale_utf8 ($) { # Return a boolean as to if core Perl thinks the input
524                          # is a UTF-8 locale
525
526     # On z/OS, even locales marked as UTF-8 aren't.
527     return 0 if ord "A" != 65;
528
529     return 0 unless locales_enabled('LC_CTYPE');
530
531     my $locale = shift;
532
533     use locale;
534     no warnings 'locale'; # We may be trying out a weird locale
535
536     my $save_locale = setlocale(&POSIX::LC_CTYPE());
537     if (! $save_locale) {
538         ok(0, "Verify could save previous locale");
539         return 0;
540     }
541
542     if (! setlocale(&POSIX::LC_CTYPE(), $locale)) {
543         ok(0, "Verify could setlocale to $locale");
544         return 0;
545     }
546
547     my $ret = 0;
548
549     # Use an op that gives different results for UTF-8 than any other locale.
550     # If a platform has UTF-8 locales, there should be at least one locale on
551     # most platforms with UTF-8 in its name, so if there is a bug in the op
552     # giving a false negative, we should get a failure for those locales as we
553     # go through testing all the locales on the platform.
554     if (CORE::fc(chr utf8::unicode_to_native(0xdf)) ne "ss") {
555         if ($locale =~ /UTF-?8/i) {
556             ok (0, "Verify $locale with UTF-8 in name is a UTF-8 locale");
557         }
558     }
559     else {
560         $ret = 1;
561     }
562
563     die "Couldn't restore locale '$save_locale'"
564         unless setlocale(&POSIX::LC_CTYPE(), $save_locale);
565
566     return $ret;
567 }
568
569 sub find_utf8_ctype_locales (;$) { # Return the names of the locales that core
570                                   # Perl thinks are UTF-8 LC_CTYPE locales.
571                                   # Optional parameter is a reference to a
572                                   # list of locales to try; if omitted, this
573                                   # tries all locales it can find on the
574                                   # platform
575     return unless locales_enabled('LC_CTYPE');
576
577     my $locales_ref = shift;
578     my @return;
579
580     if (! defined $locales_ref) {
581
582         my @locales = find_locales(&POSIX::LC_CTYPE());
583         $locales_ref = \@locales;
584     }
585
586     foreach my $locale (@$locales_ref) {
587         push @return, $locale if is_locale_utf8($locale);
588     }
589
590     return @return;
591 }
592
593
594 sub find_utf8_ctype_locale (;$) { # Return the name of a locale that core Perl
595                                   # thinks is a UTF-8 LC_CTYPE non-turkic
596                                   # locale.
597                                   # Optional parameter is a reference to a
598                                   # list of locales to try; if omitted, this
599                                   # tries all locales it can find on the
600                                   # platform
601     my $try_locales_ref = shift;
602
603     my @utf8_locales = find_utf8_ctype_locales($try_locales_ref);
604     my @turkic_locales = find_utf8_turkic_locales($try_locales_ref);
605
606     my %seen_turkic;
607
608     # Create undef elements in the hash for turkic locales
609     @seen_turkic{@turkic_locales} = ();
610
611     foreach my $locale (@utf8_locales) {
612         return $locale unless exists $seen_turkic{$locale};
613     }
614
615     return;
616 }
617
618 sub find_utf8_turkic_locales (;$) {
619
620     # Return the name of all the locales that core Perl thinks are UTF-8
621     # Turkic LC_CTYPE.  Optional parameter is a reference to a list of locales
622     # to try; if omitted, this tries all locales it can find on the platform
623
624     my @return;
625
626     return unless locales_enabled('LC_CTYPE');
627
628     my $save_locale = setlocale(&POSIX::LC_CTYPE());
629     foreach my $locale (find_utf8_ctype_locales(shift)) {
630         use locale;
631         setlocale(&POSIX::LC_CTYPE(), $locale);
632         push @return, $locale if uc('i') eq "\x{130}";
633     }
634     setlocale(&POSIX::LC_CTYPE(), $save_locale);
635
636     return @return;
637 }
638
639 sub find_utf8_turkic_locale (;$) {
640     my @turkics = find_utf8_turkic_locales(shift);
641
642     return unless @turkics;
643     return $turkics[0]
644 }
645
646
647 # returns full path to the directory containing the current source
648 # file, inspired by mauke's Dir::Self
649 sub _source_location {
650     require File::Spec;
651
652     my $caller_filename = (caller)[1];
653
654     my $loc = File::Spec->rel2abs(
655         File::Spec->catpath(
656             (File::Spec->splitpath($caller_filename))[0, 1], ''
657         )
658     );
659
660     return ($loc =~ /^(.*)$/)[0]; # untaint
661 }
662
663 1
664
665 # Format of data is: locale_name, language_codes, country_codes, encodings
666 __DATA__
667 Afrikaans:af:za:1 15
668 Arabic:ar:dz eg sa:6 arabic8
669 Brezhoneg Breton:br:fr:1 15
670 Bulgarski Bulgarian:bg:bg:5
671 Chinese:zh:cn tw:cn.EUC eucCN eucTW euc.CN euc.TW Big5 GB2312 tw.EUC
672 Hrvatski Croatian:hr:hr:2
673 Cymraeg Welsh:cy:cy:1 14 15
674 Czech:cs:cz:2
675 Dansk Danish:da:dk:1 15
676 Nederlands Dutch:nl:be nl:1 15
677 English American British:en:au ca gb ie nz us uk zw:1 15 cp850
678 Esperanto:eo:eo:3
679 Eesti Estonian:et:ee:4 6 13
680 Suomi Finnish:fi:fi:1 15
681 Flamish::fl:1 15
682 Deutsch German:de:at be ch de lu:1 15
683 Euskaraz Basque:eu:es fr:1 15
684 Galego Galician:gl:es:1 15
685 Ellada Greek:el:gr:7 g8
686 Frysk:fy:nl:1 15
687 Greenlandic:kl:gl:4 6
688 Hebrew:iw:il:8 hebrew8
689 Hungarian:hu:hu:2
690 Indonesian:id:id:1 15
691 Gaeilge Irish:ga:IE:1 14 15
692 Italiano Italian:it:ch it:1 15
693 Nihongo Japanese:ja:jp:euc eucJP jp.EUC sjis
694 Korean:ko:kr:
695 Latine Latin:la:va:1 15
696 Latvian:lv:lv:4 6 13
697 Lithuanian:lt:lt:4 6 13
698 Macedonian:mk:mk:1 15
699 Maltese:mt:mt:3
700 Moldovan:mo:mo:2
701 Norsk Norwegian:no no\@nynorsk nb nn:no:1 15
702 Occitan:oc:es:1 15
703 Polski Polish:pl:pl:2
704 Rumanian:ro:ro:2
705 Russki Russian:ru:ru su ua:5 koi8 koi8r KOI8-R koi8u cp1251 cp866
706 Serbski Serbian:sr:yu:5
707 Slovak:sk:sk:2
708 Slovene Slovenian:sl:si:2
709 Sqhip Albanian:sq:sq:1 15
710 Svenska Swedish:sv:fi se:1 15
711 Thai:th:th:11 tis620
712 Turkish:tr:tr:9 turkish8
713 Yiddish:yi::1 15