e2a104
diff -pruN paps-0.6.8.orig/src/paps.c paps-0.6.8/src/paps.c
e2a104
--- paps-0.6.8.orig/src/paps.c	2008-09-01 15:07:03.000000000 +0900
e2a104
+++ paps-0.6.8/src/paps.c	2008-09-01 15:49:10.000000000 +0900
e2a104
@@ -25,6 +25,7 @@
e2a104
 #include <pango/pangoft2.h>
e2a104
 #include "libpaps.h"
e2a104
 #include <errno.h>
e2a104
+#include <langinfo.h>
e2a104
 #include <stdlib.h>
e2a104
 #include <stdio.h>
e2a104
 #include <string.h>
e2a104
@@ -331,6 +332,9 @@ int main(int argc, char *argv[])
e2a104
   GIConv cvh = NULL;
e2a104
   GOptionGroup *options;
e2a104
 
e2a104
+  /* Set locale from environment. */
e2a104
+  setlocale(LC_ALL, "");
e2a104
+
e2a104
   /* Prerequisite when using glib. */
e2a104
   g_type_init();
e2a104
 
e2a104
@@ -480,6 +484,15 @@ int main(int argc, char *argv[])
e2a104
   page_layout.scale_x = page_layout.scale_y = 1.0;
e2a104
       
e2a104
 
e2a104
+  if (encoding == NULL)
e2a104
+    {
e2a104
+      encoding = g_strdup(nl_langinfo(CODESET));
e2a104
+      if (!strcmp(encoding, "UTF-8"))
e2a104
+        {
e2a104
+          g_free(encoding);
e2a104
+          encoding = NULL;
e2a104
+        }
e2a104
+    }
e2a104
   if (encoding != NULL)
e2a104
     {
e2a104
       cvh = g_iconv_open ("UTF-8", encoding);