Revision: 108
Author: nyaochi
Date: 2006-07-02 05:26:56 -0700 (Sun, 02 Jul 2006)
ViewCVS: http://svn.sourceforge.net/pmplib/?rev=108&view=rev
Log Message:
-----------
Added automatic detection of the current encoding used in a system.
Modified Paths:
--------------
trunk/frontend/easypmp/cui/option.c
Modified: trunk/frontend/easypmp/cui/option.c
===================================================================
--- trunk/frontend/easypmp/cui/option.c 2006-07-02 12:04:58 UTC (rev 107)
+++ trunk/frontend/easypmp/cui/option.c 2006-07-02 12:26:56 UTC (rev 108)
@@ -36,6 +36,10 @@
#include <direct.h> /* getcwd() */
#endif/*_MSC_VER*/
+#ifdef HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
#include <ucs2char.h>
#include <filepath.h>
#include <gmi.h>
@@ -101,6 +105,18 @@
easypmp_set_strip_words(opt, ucs2str);
}
+static char *get_default_encoding()
+{
+ const char *encoding = getenv("CHARSET");
+
+#ifdef HAVE_LANGINFO_CODESET
+ if (!encoding) {
+ encoding = nl_langinfo(CODESET);
+ }
+#endif
+ return encoding ? strdup(encoding) : strdup("UTF-8");
+}
+
void option_init(option_t* opt)
{
memset(opt, 0, sizeof(*opt));
@@ -108,6 +124,8 @@
// Set default values here.
opt->media_info_source |= (GMIF_TAG | GMIF_STRIP_ARTIST);
set_strip_words(opt, "the ");
+ opt->system_encoding = get_default_encoding();
+ opt->music_encoding = get_default_encoding();
}
void option_finish(option_t* opt)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|