summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ddd95cf)
raw | patch | inline | side by side (parent: ddd95cf)
author | Kalle Wallin <kaw@linux.se> | |
Sun, 6 Jun 2004 14:11:06 +0000 (14:11 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Sun, 6 Jun 2004 14:11:06 +0000 (14:11 +0000) |
src/main.c | patch | blob | history | |
src/support.c | patch | blob | history | |
src/support.h | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index 15ecf45322c7fba25a4d46e8d5951b8dc190dd43..1a3573e7a4a3e55c79ca080d212482fe1d8b7d98 100644 (file)
--- a/src/main.c
+++ b/src/main.c
/*
+ * $Id$
+ *
* (c) 2004 by Kalle Wallin (kaw@linux.se)
*
* This program is free software; you can redistribute it and/or modify
{
screen_exit();
printf("\n");
- charset_close();
if( mpc )
{
if( mpc_error(mpc) )
options_t *options;
struct sigaction act;
gboolean connected;
+ const char *charset = NULL;
+
+ /* initialize charset */
+#ifdef HAVE_LOCALE_H
+ if( setlocale(LC_CTYPE,"") == NULL )
+ {
+ g_printerr("setlocale() - failed!\n");
+ exit(EXIT_FAILURE);
+ }
+ charset_init(g_get_charset(&charset));
+ D(printf("charset: %s\n", charset));
+#endif
/* initialize i18n support */
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, charset);
textdomain(GETTEXT_PACKAGE);
#endif
/* parse command line options - 2 pass */
options_parse(argc, argv);
- /* initialize local charset */
- if( charset_init() )
- exit(EXIT_FAILURE);
-
/* setup signal behavior - SIGINT */
sigemptyset( &act.sa_mask );
act.sa_flags = 0;
diff --git a/src/support.c b/src/support.c
index 8cb4ecafd84a413b08c1a449e0e1809e7cedf649..6ba26121331dd0f86d45e67276793429531b5d7f 100644 (file)
--- a/src/support.c
+++ b/src/support.c
/*
+ * $Id$
+ *
* (c) 2004 by Kalle Wallin (kaw@linux.se)
*
* This program is free software; you can redistribute it and/or modify
#include "ncmpc.h"
#include "support.h"
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
-#endif
-
#define BUFSIZE 1024
extern void screen_status_printf(char *format, ...);
-static const char *charset = NULL;
-static const char *locale = NULL;
static gboolean noconvert = TRUE;
char *
}
#endif /* HAVE_STRCASESTR */
-
-int
-charset_init(void)
-{
-#ifdef HAVE_LOCALE_H
- /* get current locale */
- if( (locale=setlocale(LC_CTYPE,"")) == NULL )
- {
- g_printerr("setlocale() - failed!\n");
- return -1;
- }
-#endif
-
- /* get charset */
- noconvert = g_get_charset(&charset);
-
-#ifdef DEBUG
- g_printerr("charset: %s [%d]\n", charset, noconvert);
- fflush(stderr);
-#endif
-
- return 0;
-}
-
-int
-charset_close(void)
+void
+charset_init(gboolean disable)
{
- return 0;
+ noconvert = disable;
}
char *
&error);
if( error )
{
+ const char *charset;
+
+ g_get_charset(&charset);
screen_status_printf(_("Error: Unable to convert characters to %s"),
charset);
D(g_printerr("utf8_to_locale(): %s\n", error->message));
diff --git a/src/support.h b/src/support.h
index 1f3aca160f18bd0237b952b8eb5f68125b5394d0..2b79e3aefff261492f2b7471566b9f37e1bb5b26 100644 (file)
--- a/src/support.h
+++ b/src/support.h
char *lowerstr(char *str);
char *strcasestr(const char *haystack, const char *needle);
-int charset_init(void);
-int charset_close(void);
+void charset_init(gboolean disable);
char *utf8_to_locale(char *str);
char *locale_to_utf8(char *str);