[Freeciv-Dev] (PR#10982) server console character-encoding bugs
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10982 >
The server console doesn't handle character sets correctly.
Anyone using utf-8 won't see this. For a long time I was confused
because I was stuck in utf-8, and things kept working even though I knew
they shouldn't be. To get to latin1 I not only had to change my locale
(via the LANG environment variable) to ISO-8859-1 but also had to change
my gnome-terminal's character encoding setting.
There are three problems:
- Output isn't converted to the local encoding.
- Input isn't converted to the internal encoding.
- Readline autocompletion isn't handled correctly.
Of course the readline problem is part of the first two but big enough
to be kept separate.
This patch is a preliminary solution. It only fixes the first problem,
which is rather easy. This probably improves the behavior by about 80%
overall since users are most concerned with the output.
More to follow.
jason
Index: server/console.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/console.c,v
retrieving revision 1.23
diff -u -r1.23 console.c
--- server/console.c 1 May 2004 03:22:11 -0000 1.23
+++ server/console.c 11 Nov 2004 19:36:16 -0000
@@ -23,6 +23,7 @@
#include <readline/readline.h>
#endif
+#include "fciconv.h"
#include "fcintl.h"
#include "log.h"
#include "support.h"
@@ -99,12 +100,12 @@
va_end(args);
if(console_prompt_is_showing) {
- printf("\n");
+ fc_printf("\n");
}
if ((console_rfcstyle) && (rfc_status >= 0)) {
- printf("%.3d %s", rfc_status, buf);
+ fc_printf("%.3d %s", rfc_status, buf);
} else {
- printf("%s", buf);
+ fc_printf("%s", buf);
}
console_prompt_is_showing = FALSE;
return (int) strlen(buf);
@@ -136,12 +137,12 @@
void con_puts(enum rfc_status rfc_status, const char *str)
{
if(console_prompt_is_showing) {
- printf("\n");
+ fc_printf("\n");
}
if ((console_rfcstyle) && (rfc_status >= 0)) {
- printf("%.3d %s\n", rfc_status, str);
+ fc_printf("%.3d %s\n", rfc_status, str);
} else {
- printf("%s\n", str);
+ fc_printf("%s\n", str);
}
console_prompt_is_showing = FALSE;
con_update_prompt();
Index: utility/fciconv.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/fciconv.h,v
retrieving revision 1.6
diff -u -r1.6 fciconv.h
--- utility/fciconv.h 7 Oct 2004 14:41:05 -0000 1.6
+++ utility/fciconv.h 11 Nov 2004 19:36:16 -0000
@@ -28,6 +28,7 @@
char *data_to_internal_string_malloc(const char *text);
char *internal_to_data_string_malloc(const char *text);
+#define fc_printf(...) fc_fprintf(stdout, __VA_ARGS__)
void fc_fprintf(FILE *stream, const char *format, ...)
fc__attribute((format (printf, 2, 3)));
|
|