[Mono-list] Default Encoding for Console.In/Out/Err
Gonzalo Paniagua Javier
gonzalo@ximian.com
21 Jan 2003 21:47:17 +0100
--=-7zUQBKQQZ0FML3FyC0hD
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
El mar, 21-01-2003 a las 20:30, Alan Tam escribió:
> Dear All,
>
> I am experiencing problem when the TextWriter in Console all have encoding
> System.Text.ASCIIEncoding.
>
> I traced into the source and found that it is from
> Encoding.UnixConsoleEncoding, which is built from Encoding.Default and in
> turn from here:
>
> [MethodImpl (MethodImplOptions.InternalCall)]
> extern private static string InternalCodePage ();
>
> Is it something like a native method in Java? Where can I find the source
> code?
>
> Or does anyone know how I can manipulate the default value? It seems the
> LANG and LC_* environment variables do not help.
When I change LC_ALL it works. And if you have an ASCIIEncoding for the
Console/Default et al it's because g_get_charset () found that to be the
encoding for your console.
Compile the attached program and tell us the output.
gcc -ggdb `pkg-config --cflags glib-2.0` -c -o getenc.o getenc.c
gcc -ggdb `pkg-config --libs glib-2.0` getenc.o -o getenc
Also try changing your LC_ALL and related variables (don't forget to
export them) and run the program to see the results.
InternalCodePage () uses g_get_charset () too.
-Gonzalo
--=-7zUQBKQQZ0FML3FyC0hD
Content-Disposition: attachment; filename=getenc.c
Content-Type: text/x-c; name=getenc.c; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
#include <glib.h>
#include <locale.h>
#include <time.h>
int
main ()
{
const gchar *buffer;
setlocale (LC_ALL, "");
g_print ("%d\n", g_get_charset (&buffer));
g_print ("%s\n", buffer);
return 0;
}
--=-7zUQBKQQZ0FML3FyC0hD--