K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / sbin /
server ip : 172.67.156.115

your ip : 172.69.214.189

H O M E


Filename/usr/sbin/validlocale
Size1.73 kb
Permissionrwxr-xr-x
Ownerroot : root
Create time27-Apr-2025 09:50
Last modified28-Dec-2005 19:02
Last accessed05-Jul-2025 15:45
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
#!/usr/bin/perl -w
#
# Author: Petter Reinholdtsen <[email protected]>
# Date: 2002-02-23
#
# Test if the locale given as argument is a valid locale. If it
# is not, print on stdout the string to add to /etc/locale.gen to make
# locale-gen generate the locale (if it exists at all).

use POSIX qw(setlocale LC_ALL);

my $debug = 0;

my $defaultcharset = $ENV{"DEFAULTCHARSET"} || "ISO-8859-1";

my $supportedlist = "/usr/share/i18n/SUPPORTED";

unless (defined $ARGV[0]) {
usage();
exit 1;
}

my $LANG = $ARGV[0];

my $loc = setlocale(LC_ALL, $LANG);
if ( ! $loc) {
print STDERR "locale '$LANG' not available\n";

my ($locale) = $LANG =~ m/^([^.@]+)/;
my ($charset) = $LANG =~ m/^[^.]+\.([^@]+)/;
my ($modifier) = $LANG =~ m/(@.+)$/;

$modifier = "" unless defined $modifier;

# Hm, if charset is missing, how to we pick the correct one to
# use? Fetching the value from /usr/share/i18n/SUPPORTED should
# work on Debian.
my $codeset = "";
if (defined $charset) {
$codeset = '.' . $charset;
} else {
$charset = get_default_charset("$locale$modifier");
}

# print "L: $locale C: $charset M: $modifier\n";
print "$locale$codeset$modifier $charset\n";

exit 1;
} else {
print STDERR "locale '$LANG' valid and available\n";
exit 0;
}

sub usage {
print "Usage: $0 <locale>\n"
}

sub get_default_charset {
my ($locale) = @_;
my ($l, $c);
open(SUPPORTED, "< $supportedlist") || die "Unable to open $supportedlist";
while (<SUPPORTED>) {
chomp;
($l, $c) = split(/\s+/);
print "Checking '$l' '$c' != '$locale'\n" if $debug;
last if ($l eq $locale);
}
close(SUPPORTED);

if ($l eq $locale) {
return $c;
} else {
return $defaultcharset;
}
}