Avoid using g_strescape(), since it mangles UTF-8, (#89479, Yao Zhang.)

Wed Jul 31 12:50:51 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/queryimmodules.c: Avoid using g_strescape(),
        since it mangles UTF-8, (#89479, Yao Zhang.)
This commit is contained in:
Owen Taylor
2002-07-31 16:54:46 +00:00
committed by Owen Taylor
parent 0a786328d2
commit 30f84bb856
7 changed files with 59 additions and 1 deletions

View File

@ -41,10 +41,38 @@
#include "gtk/gtkrc.h"
#include "gtk/gtkimmodule.h"
static char *
escape_string (const char *str)
{
GString *result = g_string_new ("");
while (TRUE)
{
char c = *str++;
switch (c)
{
case '\0':
goto done;
case '\n':
g_string_append (result, "\\n");
break;
case '\"':
g_string_append (result, "\\\"");
break;
default:
g_string_append_c (result, c);
}
}
done:
return g_string_free (result, FALSE);
}
static void
print_escaped (const char *str)
{
char *tmp = g_strescape (str, NULL);
char *tmp = escape_string (str, NULL);
printf ("\"%s\" ", tmp);
g_free (tmp);
}