Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

iso_lang.c

00001 /*****************************************************************************
00002  * iso_lang.c: function to decode language code (in dvd or a52 for instance).
00003  *****************************************************************************
00004  * Copyright (C) 1998-2004 the VideoLAN team
00005  * $Id: iso_lang.c 11716 2005-07-12 18:01:14Z courmisch $
00006  *
00007  * Author: Stéphane Borel <[email protected]>
00008  *         Arnaud de Bossoreille de Ribou <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 /*****************************************************************************
00026  * Preamble
00027  *****************************************************************************/
00028 #include <stdio.h>
00029 
00030 #include <vlc/vlc.h>
00031 
00032 #include "iso_lang.h"
00033 
00034 /*****************************************************************************
00035  * Local tables
00036  *****************************************************************************/
00037 #include "iso-639_def.h"
00038 
00039 static const iso639_lang_t unknown_language =
00040     { "Unknown", "Unknown", "??", "???", "???" };
00041 
00042 /*****************************************************************************
00043  * DecodeLanguage: gives the long language name from the two-letter
00044  *                 ISO-639 code
00045  *****************************************************************************/
00046 const char * DecodeLanguage( uint16_t i_code )
00047 {
00048     const iso639_lang_t * p_lang;
00049     uint8_t psz_code[3];
00050 
00051     psz_code[0] = i_code >> 8;
00052     psz_code[1] = i_code & 0xff;
00053     psz_code[2] = '\0';
00054 
00055     for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
00056     {
00057         if( !memcmp( p_lang->psz_iso639_1, psz_code, 2 ) )
00058         {
00059 # if 0
00060             if( *p_lang->psz_native_name )
00061             {
00062                 return p_lang->psz_native_name;
00063             }
00064 #endif
00065 
00066             return _( p_lang->psz_eng_name );
00067         }
00068     }
00069 
00070     return _( "Unknown" );
00071 }
00072 
00073 const iso639_lang_t * GetLang_1( const char * psz_code )
00074 {
00075     const iso639_lang_t *p_lang;
00076 
00077     for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
00078         if( !strncmp( p_lang->psz_iso639_1, psz_code, 2 ) )
00079             return p_lang;
00080 
00081     return &unknown_language;
00082 }
00083 
00084 const iso639_lang_t * GetLang_2T( const char * psz_code )
00085 {
00086     const iso639_lang_t *p_lang;
00087 
00088     for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
00089         if( !strncmp( p_lang->psz_iso639_2T, psz_code, 3 ) )
00090             return p_lang;
00091 
00092     return &unknown_language;
00093 }
00094 
00095 const iso639_lang_t * GetLang_2B( const char * psz_code )
00096 {
00097     const iso639_lang_t *p_lang;
00098 
00099     for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
00100         if( !strncmp( p_lang->psz_iso639_2B, psz_code, 3 ) )
00101             return p_lang;
00102 
00103     return &unknown_language;
00104 }
00105 

Generated on Tue Dec 20 10:15:00 2005 for vlc-0.8.4a by  doxygen 1.4.2