2023-02-25 23:06:34 +08:00
|
|
|
#!/bin/bash
|
|
|
|
(
|
|
|
|
cat <<-EOF
|
|
|
|
/* This struct of default codesets has been generated by fetching
|
|
|
|
locale data from a Linux system using $(rpm -q glibc | head -1) on $(date +%F) */
|
|
|
|
struct default_codeset_t
|
|
|
|
{
|
|
|
|
const char *locale;
|
|
|
|
const char *codeset;
|
|
|
|
} default_codeset[] =
|
|
|
|
{
|
|
|
|
EOF
|
2023-02-26 03:15:53 +08:00
|
|
|
locale -av | \
|
|
|
|
awk '/^locale:/{
|
|
|
|
if ( index ($2, "_") == 0 ) next # No aliases
|
|
|
|
if ( index ($2, ".") > 0 ) next # No explicit codesets
|
|
|
|
locale=$2;
|
|
|
|
}
|
|
|
|
/codeset/ {
|
|
|
|
if ( length (locale) == 0 ) next
|
|
|
|
codeset = gensub (/BIG5.*/, "BIG5", 1, $3);
|
|
|
|
printf " { \"%s\", \"%s\" },\n", locale, codeset;
|
|
|
|
locale = "";
|
|
|
|
}'
|
2023-02-25 23:06:34 +08:00
|
|
|
echo "};"
|
|
|
|
) > lc_def_codesets.h
|