Re: iconv returning byte order marks for Solaris 2.9

Andrew
2009-07-15T19:50:50Z

In the system I'm working iconv_open doesn't accept "wchar_t" as encoding name. It failed when INTERMEDIATE_ENCODING was set to that.

But setting INTERMEDIATE_ENCODING to "UCS-4BE" eliminated the BOM in the beginning.

Andrew

--- On Wed, 7/15/09, Tom Tromey <tromey@redhat.com> wrote:

> From: Tom Tromey <tromey@redhat.com>
> Subject: Re: iconv returning byte order marks for Solaris 2.9
> To: ke@alum.bu.edu
> Cc: gdb-patches@sourceware.org
> Date: Wednesday, July 15, 2009, 2:24 PM
> >>>>> "Andrew" ==
> Andrew  <ke@alum.bu.edu>
> writes:
>
> Andrew> I found a problem printing strings for gdb 6.8
> weekly snapshot
> Andrew> (2009 07 07) on Solaris 2.9.
>
> Thanks for finding and diagnosing this.
>
> Andrew> I eventually found that changing
> INTERMEDIATE_ENCODING
> Andrew> in gdb_wchar.h to "UCS-4" and applying the
> following
> Andrew> patch worked. Any comments?
>
> Andrew> I'm not sure how to handle the
> INTERMEDIATE_ENCODING
> Andrew> change, since it's probably system dependent.
>
> I don't have access to Solaris.  If I understand
> correctly, the
> situation is:
>
> * wchar_t on Solaris is encoded using UCS-4
> * iconv_open accepts "wchar_t" as an encoding name
> * in this case, iconv emits a BOM
>
> First, this seems like it must be a Solaris bug, just
> because I can't
> imagine how this would be useful.
>
> I don't think we can use your patch as-is.  It does
> the BOM elimination
> unconditionally, but really I think we can only do it on
> platforms where
> we know that wchar_t is UCS-4 (or UCS-2 I suppose).
>
> Does Solaris 9 support a full suite of conversions?
> If not, one option
> would be to use libiconv, and find a way to disable most of
> this code by
> default on Solaris.
>
> Failing that, the simplest fix would be if there is an
> encoding
> (compatible with wchar_t) we can use on Solaris which does
> not insert
> the BOM.  For example, maybe "UCS-4BE" or "UCS-4LE",
> depending on the
> architecture.  I think a fix like this could be done
> entirely in
> gdb_wchar.h.  Could you try that?
>
> As far as the host dependency, we can probably just check
> __STDC_ISO_10646__.
>
> Tom
>