Hi Mike,

now I completely reworked the patch, enhanced and tested it.

Now it takes the defaults only when no encoding can be found. But it
should be found normally from the environment.

Sorry for the bad done patch before. I do not know why I took this one
to sent to you.

Regards
   Klaus
-- 
Klaus Ethgen                            http://www.ethgen.de/
pub  2048R/D1A4EDE5 2000-02-26 Klaus Ethgen <[EMAIL PROTECTED]>
Fingerprint: D7 67 71 C4 99 A6 D4 FE  EA 40 30 57 3C 88 26 2B
commit 7b34b964d0c2478a3c6dab9eabe69fe60b9ea97f
Author: Klaus Ethgen <[EMAIL PROTECTED]>
Date:   Wed Jun 18 21:49:11 2008 +0100

    Fixing the encoding to stay in sync with the documentation.
    
    The INPUT_ENCODING was set wrong to UTF-8. But the documentation says that the
    default is ISO-8859-1.
    
    This has the effect that scrollz do stop working when the first ISO-8859-1
    character > 0x7f is typed! The changes switch to the documented default and will
    work also if the real input encoding is not right as ISO-8859-1 is a full 8bit
    encoding.
    
    Please note that the historical default on IRC is allways a 8bit encoding.
    
    Futermore this will use the locale variables to set the encoding.
    
    Closes: #398345

diff --git a/debian/changelog b/debian/changelog
index 8b3db58..92f7729 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+scrollz (1.9.99-1.2) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Fixing the encoding to stay in sync with the documentation. (Closes:
+    #398345)
+
+ -- Klaus Ethgen <[EMAIL PROTECTED]>  Wed, 18 Jun 2008 21:37:57 +0100
+
 scrollz (1.9.99-1.1) unstable; urgency=low
 
   * Non-maintainer upload.
diff --git a/include/config.h b/include/config.h
index 95ed923..73209ab 100644
--- a/include/config.h
+++ b/include/config.h
@@ -132,7 +132,7 @@
 #define DEFAULT_CTCP_REPLY_IGNORE_SECONDS 10
 #define DEFAULT_DCC_BLOCK_SIZE 2048
 #define DEFAULT_DISPLAY 1
-#define DEFAULT_DISPLAY_ENCODING "UTF-8"
+#define DEFAULT_DISPLAY_ENCODING "ISO8859-1"
 #define DEFAULT_DISPLAY_ANSI 1
 #define DEFAULT_EIGHT_BIT_CHARACTERS 1
 #define DEFAULT_ENCRYPT_PROGRAM NULL
@@ -156,10 +156,10 @@
 #define DEFAULT_HYPER_DCC 0
 #define DEFAULT_INDENT 1
 #define DEFAULT_INPUT_ALIASES 0
-#define DEFAULT_INPUT_ENCODING "UTF-8"
+#define DEFAULT_INPUT_ENCODING "ISO-8859-1"
 #define DEFAULT_INPUT_PROMPT NULL
 #define DEFAULT_INPUT_PROTECTION 1
-#define DEFAULT_IRC_ENCODING "UTF-8"
+#define DEFAULT_IRC_ENCODING "ISO-8859-1"
 #define DEFAULT_INSERT_MODE 1
 #define DEFAULT_INVERSE_VIDEO 1
 #define DEFAULT_ISO2022_SUPPORT 0
diff --git a/include/irc.h b/include/irc.h
index 8610fd6..069faf1 100644
--- a/include/irc.h
+++ b/include/irc.h
@@ -131,6 +131,9 @@
 # endif
 #endif
 
+#include <langinfo.h>
+#include <locale.h>
+
 #ifdef HAVE_SYS_SELECT_H
 # include <sys/select.h>
 #endif
diff --git a/source/vars.c b/source/vars.c
index 00a88a7..ebe0e61 100644
--- a/source/vars.c
+++ b/source/vars.c
@@ -351,6 +351,13 @@ init_variables()
 /**************************** PATCHED by Flier ******************************/
         int old_disp;
 /****************************************************************************/
+	char *charset;
+
+	/* Switch the locale to the environment values to get the right charset */
+	setlocale(LC_ALL, "");
+	charset = nl_langinfo(CODESET);
+	/* Switch back to the locale used before (POSIX or C) to prevent side effects. */
+	setlocale(LC_ALL, "C");
 
 	check_variable_order();
 
@@ -359,12 +366,22 @@ init_variables()
 	set_string_var(SHELL_VAR, DEFAULT_SHELL);
 	set_string_var(SHELL_FLAGS_VAR, DEFAULT_SHELL_FLAGS);
 	set_string_var(DECRYPT_PROGRAM_VAR, UP(DEFAULT_DECRYPT_PROGRAM));
-	set_string_var(DISPLAY_ENCODING_VAR, DEFAULT_DISPLAY_ENCODING);
 	set_string_var(ENCRYPT_PROGRAM_VAR, DEFAULT_ENCRYPT_PROGRAM);
 	set_string_var(CONTINUED_LINE_VAR, DEFAULT_CONTINUED_LINE);
-	set_string_var(INPUT_ENCODING_VAR, DEFAULT_INPUT_ENCODING);
+	if (charset == NULL || charset[0] == '\0')
+	{
+	   set_string_var(DISPLAY_ENCODING_VAR, DEFAULT_DISPLAY_ENCODING);
+	   set_string_var(INPUT_ENCODING_VAR, DEFAULT_INPUT_ENCODING);
+	   set_string_var(IRC_ENCODING_VAR, DEFAULT_IRC_ENCODING);
+	}
+	else
+	{
+	   set_string_var(DISPLAY_ENCODING_VAR, charset);
+	   set_string_var(INPUT_ENCODING_VAR, charset);
+	   set_string_var(IRC_ENCODING_VAR, charset);
+	}
+
 	set_string_var(INPUT_PROMPT_VAR, DEFAULT_INPUT_PROMPT);
-	set_string_var(IRC_ENCODING_VAR, DEFAULT_IRC_ENCODING);
 	set_string_var(HIGHLIGHT_CHAR_VAR, DEFAULT_HIGHLIGHT_CHAR);
 	set_string_var(HISTORY_FILE_VAR, DEFAULT_HISTORY_FILE);
 	set_string_var(LASTLOG_LEVEL_VAR, DEFAULT_LASTLOG_LEVEL);

Attachment: signature.asc
Description: Digital signature

Reply via email to