Commit f388eb55 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* added a vlc_current_charset function. This tries to get the current charset

  in use by the OS. It's pretty nifty. if available it uses nl_langinfo. Then
  it falls back to trying setlocale (exept on OSX, where this funtion is useless)
  and then falls back to LC_ALL, LC_TYPE and LANG environment variables.
  If only the LANG variable is available (like on osx) it tries a countrycode
  to charset mapping (making an educated guess ).
  On windows it retrieves the charset with GetACP().
  It also has an aliases system to transform incompatible charset description
  strings to libiconv compatible charset descriptions. If you want you can even
  retrieve the charset on OS/2.
* modules/codec/subsdec/subsdec.c: By default we try to open a subtitle file in
  the systems charset (or language mapped to charset). It's no more than a guess,
  and if you open Latin1 subs on your Japanese system you will still need to
  specify the encoding by hand, but it's better then nothing.
* src/playlist/playlist.c: spelling error in a comment.
parent 190f4a1e
......@@ -69,6 +69,7 @@ HEADERS_include = \
include/beos_specific.h \
include/configuration.h \
include/darwin_specific.h \
include/charset.h \
include/codecs.h \
include/encoder.h \
include/ninput.h \
......@@ -314,6 +315,7 @@ SOURCES_libvlc_common = \
src/audio_output/output.c \
src/audio_output/intf.c \
src/stream_output/stream_output.c \
src/misc/charset.c \
src/misc/mtime.c \
src/misc/modules.c \
src/misc/threads.c \
......
dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.65 2003/08/23 12:47:24 lool Exp $
dnl $Id: configure.ac,v 1.66 2003/08/23 12:59:31 hartman Exp $
AC_INIT(vlc,0.6.3-cvs)
......@@ -255,6 +255,22 @@ AC_CHECK_FUNCS(strdup strndup atof lseek)
AC_CHECK_FUNCS(strcasecmp,,[AC_CHECK_FUNCS(stricmp)])
AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)])
dnl Check for setlocal and langinfo
AC_CHECK_FUNCS(setlocale)
AC_CHECK_HEADERS(langinfo.h)
AC_CHECK_FUNCS(nl_langinfo)
AC_CACHE_CHECK([for nl_langinfo and CODESET], ac_cv_langinfo_codeset,
[AC_TRY_LINK([#include <langinfo.h>],
[char* cs = nl_langinfo(CODESET);],
ac_cv_langinfo_codeset=yes,
ac_cv_langinfo_codeset=no)
])
if test ${ac_cv_langinfo_codeset} = yes; then
AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
fi
AC_CHECK_FUNCS(connect,,[
AC_CHECK_LIB(socket,connect,[
AX_ADD_LDFLAGS([vlc ipv4],-lsocket)
......
/*****************************************************************************
* charset.h: Determine a canonical name for the current locale's character encoding.
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: charset.h,v 1.1 2003/08/23 12:59:31 hartman Exp $
*
* Author: Derk-Jan Hartman <thedj at users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
VLC_EXPORT( vlc_bool_t, vlc_current_charset, ( char ** ) );
......@@ -2,7 +2,7 @@
* subsdec.c : SPU decoder thread
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: subsdec.c,v 1.5 2003/08/10 10:22:52 gbazin Exp $
* $Id: subsdec.c,v 1.6 2003/08/23 12:59:31 hartman Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Samuel Hocevar <sam@zoy.org>
......@@ -34,6 +34,7 @@
#include <osd.h>
#include "subsdec.h"
#include "charset.h"
/*****************************************************************************
* Local prototypes
......@@ -47,7 +48,8 @@ static vout_thread_t *FindVout( subsdec_thread_t * );
/*****************************************************************************
* Module descriptor.
*****************************************************************************/
static char *ppsz_encodings[] = { "ASCII", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3",
static char *ppsz_encodings[] = { N_("System Default"),
"ASCII", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3",
"ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8",
"ISO-8859-9", "ISO-8859-10", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15",
"ISO-8859-16", "ISO-2022-JP", "ISO-2022-JP-1", "ISO-2022-JP-2", "ISO-2022-CN",
......@@ -78,7 +80,7 @@ vlc_module_begin();
add_integer( "subsdec-align", 0, NULL, ALIGN_TEXT, ALIGN_LONGTEXT, VLC_TRUE );
#if defined(HAVE_ICONV)
add_string_from_list( "subsdec-encoding", "ISO-8859-1", ppsz_encodings, NULL, ENCODING_TEXT, ENCODING_LONGTEXT, VLC_FALSE );
add_string_from_list( "subsdec-encoding", N_("System Default"), ppsz_encodings, NULL, ENCODING_TEXT, ENCODING_LONGTEXT, VLC_FALSE );
#endif
vlc_module_end();
......@@ -149,7 +151,16 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
/* Here we are dealing with text subtitles */
#if defined(HAVE_ICONV)
var_Get( p_subsdec->p_fifo, "subsdec-encoding", &val );
p_subsdec->iconv_handle = iconv_open( "UTF-8", val.psz_string);
if( strcmp( val.psz_string, N_("System Default") ) == 0 )
{
char *psz_charset =(char*)malloc( 100 );
vlc_current_charset(&psz_charset);
p_subsdec->iconv_handle = iconv_open( "UTF-8", psz_charset );
}
else
{
p_subsdec->iconv_handle = iconv_open( "UTF-8", val.psz_string );
}
if( p_subsdec->iconv_handle == (iconv_t)-1 )
{
msg_Warn( p_subsdec->p_fifo, "Unable to do requested conversion" );
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* playlist.c : Playlist management functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: playlist.c,v 1.45 2003/08/17 14:14:01 sigmunau Exp $
* $Id: playlist.c,v 1.46 2003/08/23 12:59:31 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -134,7 +134,7 @@ int playlist_Add( playlist_t *p_playlist, const char *psz_target,
* \param ppsz_options array of options
* \param i_options number of items in ppsz_options
* \param i_mode the mode used when adding
* \param i_pos the possition in the playlist where to add. If this is
* \param i_pos the position in the playlist where to add. If this is
* PLAYLIST_END the item will be added at the end of the playlist
* regardless of it's size
* \return always returns 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment