summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author <urmaslt@svn.abisource.com>2011-07-10 15:02:34 +0000
committer <urmaslt@svn.abisource.com>2011-07-10 15:02:34 +0000
commite1a436c50c399ebfd397b6b042fce45b77552c88 (patch)
tree5073b08e2c3cfa8fb51390aafe1d987623f2f9b4
parentb5a97020c46a6dc279a064f1c848717b217cd9f2 (diff)
downloadenchant-e1a436c50c399ebfd397b6b042fce45b77552c88.tar.gz
Fixes encoding problems on Windows
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@30014 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r--tests/enchant-ispell.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/enchant-ispell.c b/tests/enchant-ispell.c
index 639d74b..9c5f1c7 100644
--- a/tests/enchant-ispell.c
+++ b/tests/enchant-ispell.c
@@ -51,6 +51,12 @@
/* word has to be bigger than this to be checked */
#define MIN_WORD_LENGTH 1
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+static char charset[15] = "CP437";
+#endif
typedef enum
{
@@ -100,7 +106,11 @@ consume_line (FILE * in, GString * str)
}
if (str->len) {
+#ifdef WIN32
+ utf = g_convert(str->str, str->len, "UTF-8", charset, &bytes_read, &bytes_written, NULL);
+#else
utf = g_locale_to_utf8 (str->str, str->len, &bytes_read, &bytes_written, NULL);
+#endif
if (utf) {
g_string_assign (str, utf);
@@ -468,6 +478,15 @@ int main (int argc, char ** argv)
/* Initialize system locale */
setlocale(LC_ALL, "");
+#ifdef WIN32
+ /* Workaround about glib's "locale" not being the set C locale */
+ if (GetFileType(GetStdHandle(STD_INPUT_HANDLE)) != FILE_TYPE_CHAR) {
+ sprintf_s(charset,15,"CP%u",GetACP());
+ } else {
+ sprintf_s(charset,15,"CP%u",GetConsoleCP());
+ }
+#endif
+
for (i = 1; i < argc; i++) {
char * arg = argv[i];
if (arg[0] == '-') {