public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Tom Tromey <tom@tromey.com>
Cc: Patrick Monnerat <patrick@monnerat.net>,
	 Patrick Monnerat via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb: add UTF16/UTF32 target charsets in phony_iconv
Date: Sat, 15 Oct 2022 19:50:31 -0600	[thread overview]
Message-ID: <878rlgedug.fsf@tromey.com> (raw)
In-Reply-To: <87zge3irph.fsf@tromey.com> (Tom Tromey's message of "Mon, 10 Oct 2022 10:11:38 -0600")

[ UTF-32 as intermediate encoding ]

Patrick> I nevertheless don't have any idea what is the amount of work required
Patrick> to change this.

Tom> I did most of it already.

After digging deeper into this, I think it can't work.  iswprint can
take the locale into account, and without this, we can end up in a
situation where the host-wide-char (or in this case utf-32) conversion
to the host multibyte charset ends up having to emit unnecessary
escapes.

For example in wchar.exp, \242 ends up being emitted as '\242\0\0\0',
because the \242 can't be converted to ASCII.  I think this happens
because gdb_iswprint in the utf-32 formulation disagrees with the iconv
conversion.

However, I think there's a better way to fix all this.  It's very simple
and offhand I don't know why I didn't think of it before... the use of
wchar_t depends on knowing the encoding of wchar_t -- and I think we do
know this on mingw, as it's a form of UTF-16.  So, maybe all that's
needed is a host-is-windows check in gdb_wchar.h, combined with a
suitable definition of INTERMEDIATE_ENCODING.

Can you try this?  Or if you'd prefer, I can send a patch for you to try.

thanks,
Tom

  reply	other threads:[~2022-10-16  1:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 14:00 Patrick Monnerat
2022-10-07 20:10 ` Tom Tromey
2022-10-08  0:12   ` Patrick Monnerat
2022-10-08 18:55     ` Tom Tromey
2022-10-09  0:47       ` Patrick Monnerat
2022-10-10 16:11         ` Tom Tromey
2022-10-16  1:50           ` Tom Tromey [this message]
2022-10-16  6:24             ` Eli Zaretskii
2022-10-17 23:10               ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878rlgedug.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=patrick@monnerat.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).