This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: gcj -vs- iconv
On Mon, Mar 06, 2000 at 03:07:45PM -0800, Tom Tromey wrote:
> Zack> setlocale (LC_CTYPE, "");
> Zack> cset = nl_langinfo (CODESET);
>
> Zack> might give you what you want. nl_langinfo is in <langinfo.h>.
>
> Do you mean _NL_CTYPE_CODESET_NAME? That is in my langinfo.h, but it
> isn't documented in my glibc info manual.
My langinfo.h has this:
_NL_CTYPE_CODESET_NAME,
CODESET = _NL_CTYPE_CODESET_NAME,
#define CODESET CODESET
I'm betting that CODESET is the standardized name, while
_NL_CTYPE_CODESET_NAME is the internal name. I don't think you're
supposed to use the values that start with _NL_. (Ulrich?)
Solaris langinfo.h has CODESET but not _NL_CTYPE_CODESET_NAME.
Also, from testing on Solaris, you need to deal with nl_langinfo
returning an empty string, or NULL.
> Anyway, thanks. I'll update my patch to do this.
Sure.
> Zack> I think there ought to be a way to specify the encoding of a
> Zack> file *inside* the file. How does Mule do it?
>
> I don't know how Mule does it. For Java this would have to be in a
> special comment or something like that. Even then I don't see how it
> can work unless you pick a default encoding, like ASCII.
Mule extends the standard Emacs magic comment.
/* -*- mode: java; coding: latin-1 -*- */
would force it to treat the file as ISO8859.1. Of course, you need to
map those names to iconv names...
If it doesn't find such a comment, yes, it has a series of defaults to
fall back on.
zw