Message ID | 200705011712.19886.zzam@gentoo.org |
---|---|
State | New |
Headers |
Received: from mail-out.m-online.net ([212.18.0.9]) by www.linuxtv.org with esmtp (Exim 4.50) id 1Hiu1f-0003ec-Lc for vdr@linuxtv.org; Tue, 01 May 2007 17:12:23 +0200 Received: from mail01.m-online.net (svr21.m-online.net [192.168.3.149]) by mail-out.m-online.net (Postfix) with ESMTP id 298FD98369 for <vdr@linuxtv.org>; Tue, 1 May 2007 17:12:21 +0200 (CEST) Received: from gauss.x.fun (DSL01.83.171.145.117.ip-pool.NEFkom.net [83.171.145.117]) by mail.nefkom.net (Postfix) with ESMTP id 0FAD09037D for <vdr@linuxtv.org>; Tue, 1 May 2007 17:12:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by gauss.x.fun (Postfix) with ESMTP id A4DEF3A52 for <vdr@linuxtv.org>; Tue, 1 May 2007 17:12:20 +0200 (CEST) From: Matthias Schwarzott <zzam@gentoo.org> To: vdr@linuxtv.org Date: Tue, 1 May 2007 17:12:19 +0200 User-Agent: KMail/1.9.6 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_Tj1NGPL8MJmcweM" Message-Id: <200705011712.19886.zzam@gentoo.org> Subject: [vdr] [PATCH] Small change to correctly query the systems charset X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List <vdr@linuxtv.org> List-Id: VDR Mailing List <vdr.linuxtv.org> List-Unsubscribe: <http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr>, <mailto:vdr-request@linuxtv.org?subject=unsubscribe> List-Archive: <http://www.linuxtv.org/pipermail/vdr> List-Post: <mailto:vdr@linuxtv.org> List-Help: <mailto:vdr-request@linuxtv.org?subject=help> List-Subscribe: <http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr>, <mailto:vdr-request@linuxtv.org?subject=subscribe> X-List-Received-Date: Tue, 01 May 2007 15:12:23 -0000 Status: O X-Status: X-Keywords: X-UID: 12777 |
Commit Message
Matthias Schwarzott
May 1, 2007, 3:12 p.m. UTC
Hi there! This patch just changes charset querying to not only look at environment variable LANG, but respect all in correct order. So now I can overwrite charset setting with LC_CTYPE and LC_ALL. Greetings Matthias
Comments
> This patch just changes charset querying to not only look at environment > variable LANG, but respect all in correct order. So now I can overwrite > charset setting with LC_CTYPE and LC_ALL. Just curious, why would you need to query anything other than the environment LANG variable? If that tells you what the user wants to use, there's no need to look any further. Unless it's empty I guess? Thanks.
VDR User wrote: >> This patch just changes charset querying to not only look at environment >> variable LANG, but respect all in correct order. So now I can overwrite >> charset setting with LC_CTYPE and LC_ALL. > > Just curious, why would you need to query anything other than the > environment LANG variable? If that tells you what the user wants to > use, there's no need to look any further. Unless it's empty I guess? From man 7 locale: > If the second argument to setlocale() is empty string, "", for the > default locale, it is determined using the following steps: > > 1. If there is a non-null environment variable LC_ALL, the value of > LC_ALL is used. > 2. If an environment variable with the same name as one of the cat- > egories above exists and is non-null, its value is used for that > category. > 3. If there is a non-null environment variable LANG, the value of > LANG is used. In other words, the locale system can be set in environment by three different ways, by setting LANG (lowest precedence), by setting specific language aspects (LC_CTYPE describes just character sets, not sorting, numeric notation, date notation etc), or by setting LC_ALL (highest precedence). Even if LANG is set, it may not be valid, because other settings can override it. And not on all systems LANG is used to set the locale. Cheers, Udo
On 05/01/07 17:12, Matthias Schwarzott wrote: > Hi there! > > This patch just changes charset querying to not only look at environment > variable LANG, but respect all in correct order. So now I can overwrite > charset setting with LC_CTYPE and LC_ALL. > > Greetings > Matthias > > > > ------------------------------------------------------------------------ > > diff -ru vdr-1.5.2-vanilla/vdr.c vdr-1.5.2/vdr.c > --- vdr-1.5.2-vanilla/vdr.c 2007-05-01 17:04:45.000000000 +0200 > +++ vdr-1.5.2/vdr.c 2007-05-01 17:05:18.000000000 +0200 > @@ -493,7 +493,7 @@ > > // Set the system character table: > > - char *LangEnv = getenv("LANG"); > + char *LangEnv = setlocale(LC_CTYPE, ""); > if (LangEnv) { > char *CodeSet = strchr(LangEnv, '.'); > if (CodeSet) { > > > ------------------------------------------------------------------------ If I make this change and run VDR with export LANG=de_DE.iso8859-15 I get a NULL pointer from the setlocale(LC_CTYPE, "") call. Only with export LANG=de_DE.iso8859-1 do I get a non-NULL result. Am I missing something here? Klaus
On Sun, May 06, 2007 at 11:50:21AM +0200, Klaus Schmidinger wrote: > If I make this change and run VDR with > > export LANG=de_DE.iso8859-15 > > I get a NULL pointer from the setlocale(LC_CTYPE, "") call. > Only with > > export LANG=de_DE.iso8859-1 > > do I get a non-NULL result. > Am I missing something here? Maybe you don't have the locale files for iso8859-15 installed? (At least in Debian you can choose to install only a subset of the glibc locale files.) HTH, Johannes
Klaus Schmidinger wrote: > If I make this change and run VDR with > > export LANG=de_DE.iso8859-15 > > I get a NULL pointer from the setlocale(LC_CTYPE, "") call. > Only with > > export LANG=de_DE.iso8859-1 > > do I get a non-NULL result. > Am I missing something here? Do you have a de_DE.iso8859-15 installed? It's called de_DE@euro here (yes, that naming is "a bit" strange). You can check with "locale -a | grep de" to find the installed locales for "de". If no suitable locale is there, you can use locale-gen (at least on Debian and Gentoo) or localedef to install the missing locale. Regards... Michael
On 05/01/07 17:12, Matthias Schwarzott wrote: > Hi there! > > This patch just changes charset querying to not only look at environment > variable LANG, but respect all in correct order. So now I can overwrite > charset setting with LC_CTYPE and LC_ALL. > > Greetings > Matthias > > > > ------------------------------------------------------------------------ > > diff -ru vdr-1.5.2-vanilla/vdr.c vdr-1.5.2/vdr.c > --- vdr-1.5.2-vanilla/vdr.c 2007-05-01 17:04:45.000000000 +0200 > +++ vdr-1.5.2/vdr.c 2007-05-01 17:05:18.000000000 +0200 > @@ -493,7 +493,7 @@ > > // Set the system character table: > > - char *LangEnv = getenv("LANG"); > + char *LangEnv = setlocale(LC_CTYPE, ""); > if (LangEnv) { > char *CodeSet = strchr(LangEnv, '.'); > if (CodeSet) { It's been a while since this, and there have been some changes in the meantime. Can you please check the latest developer version (1.5.7) and see whether this works correctly now? Klaus
diff -ru vdr-1.5.2-vanilla/vdr.c vdr-1.5.2/vdr.c --- vdr-1.5.2-vanilla/vdr.c 2007-05-01 17:04:45.000000000 +0200 +++ vdr-1.5.2/vdr.c 2007-05-01 17:05:18.000000000 +0200 @@ -493,7 +493,7 @@ // Set the system character table: - char *LangEnv = getenv("LANG"); + char *LangEnv = setlocale(LC_CTYPE, ""); if (LangEnv) { char *CodeSet = strchr(LangEnv, '.'); if (CodeSet) {