public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: locale: new script creating linux default codeset mapping Date: Sat, 25 Feb 2023 15:25:04 +0000 (GMT) [thread overview] Message-ID: <20230225152504.65168385559E@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7b591704b886ab60a6c31363bd776acafb32ed09 commit 7b591704b886ab60a6c31363bd776acafb32ed09 Author: Corinna Vinschen <corinna@vinschen.de> AuthorDate: Sat Feb 25 16:06:34 2023 +0100 Commit: Corinna Vinschen <corinna@vinschen.de> CommitDate: Sat Feb 25 16:12:51 2023 +0100 Cygwin: locale: new script creating linux default codeset mapping New script creating a mapping table from locale to default codeset for this locale. We use that in Cygwin now to generate the own default codeset mapping based on Linux locale names. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- .../fetch-lc-def-codesets-from-linux | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux b/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux new file mode 100755 index 000000000000..c8c60ecac38d --- /dev/null +++ b/winsup/cygwin/linux-locale-helpers/fetch-lc-def-codesets-from-linux @@ -0,0 +1,48 @@ +#!/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 + while read line + do + locale=$(echo "${line}" | awk '/^locale:/{ print $2; }') + if [ -z "${locale}" ] + then + continue + fi + # No aliases + idx=$(expr index "${locale}" '_') + if [ "${idx}" -eq 0 ] + then + continue + fi + # No explicit codesets + idx=$(expr index "${locale}" '.') + if [ "${idx}" -ne 0 ] + then + continue + fi + while read line2 + do + codeset=$(echo "${line2}" | awk '/codeset/{ print $3; }') + if [ -n "${codeset}" ] + then + # Translate into internal codeset names. */ + case "${codeset}" in + BIG5*) codeset="BIG5";; + *) ;; + esac + printf " { \"%s\", \"%s\" },\n" "${locale}" "${codeset}" + break + fi + done + done <<<$(locale -av) + echo "};" +) > lc_def_codesets.h
reply other threads:[~2023-02-25 15:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230225152504.65168385559E@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).