summaryrefslogtreecommitdiff
path: root/i18n.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-10-08 11:28:15 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2006-10-08 11:28:15 +0200
commita9d6bb256d53f5cc16679b856d4cc5c0cc5b98c1 (patch)
tree3260605c195e8c7c9cfd0b7c6fffaf673d0f0a93 /i18n.c
parent29c0f9e1e07e0ca00870e7b8e2f2c9457af80ec5 (diff)
downloadvdr-a9d6bb256d53f5cc16679b856d4cc5c0cc5b98c1.tar.gz
vdr-a9d6bb256d53f5cc16679b856d4cc5c0cc5b98c1.tar.bz2
Replacing blanks in language codes with underlines1.4.3-1
Diffstat (limited to 'i18n.c')
-rw-r--r--i18n.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/i18n.c b/i18n.c
index 67d2927b..ee529d4a 100644
--- a/i18n.c
+++ b/i18n.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: i18n.c 1.283 2006/10/07 12:18:10 kls Exp $
+ * $Id: i18n.c 1.284 2006/10/08 08:50:30 kls Exp $
*
* Translations provided by:
*
@@ -6243,12 +6243,31 @@ int I18nLanguageIndex(const char *Code)
const char *I18nNormalizeLanguageCode(const char *Code)
{
- if (Code[0] && !isprint(Code[0]) || Code[1] && !isprint(Code[1]) || Code[2] && !isprint(Code[2])) {
- // ISO 639 language codes are defined as alphabetical characters, but digits are apparently
- // also used, for instance for "2ch". There are even channels that use blank characters.
- //dsyslog("invalid language code: '%s'", Code);
- return "???";
- }
+ for (int i = 0; i < 3; i++) {
+ if (Code[i]) {
+ // ETSI EN 300 468 defines language codes as consisting of three letters
+ // according to ISO 639-2. This means that they are supposed to always consist
+ // of exactly three letters in the range a-z - no digits, UTF-8 or other
+ // funny characters. However, some broadcasters apparently don't have a
+ // copy of the DVB standard (or they do, but are perhaps unable to read it),
+ // so they put all sorts of non-standard stuff into the language codes,
+ // like nonsense as "2ch" or "A 1" (yes, they even go as far as using
+ // blanks!). Such things should go into the description of the EPG event's
+ // ComponentDescriptor.
+ // So, as a workaround for this broadcaster stupidity, let's ignore
+ // language codes with unprintable characters...
+ if (!isprint(Code[i])) {
+ //dsyslog("invalid language code: '%s'", Code);
+ return "???";
+ }
+ // ...and replace blanks with underlines (ok, this breaks the 'const'
+ // of the Code parameter - but hey, it's them who started this):
+ if (Code[i] == ' ')
+ *((char *)&Code[i]) = '_';
+ }
+ else
+ break;
+ }
int n = I18nLanguageIndex(Code);
return n >= 0 ? I18nLanguageCode(n) : Code;
}