From: Eli Zaretskii <eliz@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: emacs-devel@gnu.org
Subject: Re: master 02bca34: Utilize new string decoding feature in GTK native input
Date: Sat, 19 Feb 2022 14:36:43 +0200 [thread overview]
Message-ID: <838ru7yqw4.fsf@gnu.org> (raw)
In-Reply-To: <87y227mal9.fsf@yahoo.com> (message from Po Lu on Sat, 19 Feb 2022 18:09:38 +0800)
> From: Po Lu <luangruo@yahoo.com>
> Cc: emacs-devel@gnu.org
> Date: Sat, 19 Feb 2022 18:09:38 +0800
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Is this a good idea? Consing a string when we process input increases
> > GC pressure, and what issues does this change solve as a
> > counter-weight for that disadvantage? Is g_utf8_to_ucs4 a problematic
> > API or something?
>
> No, but some input method modules don't always return valid UTF-8 like
> they're supposed to, thereby causing crashes in g_utf8_to_ucs4_fast.
>
> I should have explained that in the commit message.
You can still explain that in a comment to the code.
> > But in general, decoding UTF-8 encoded C string is better done without
> > consing a string and then using the coding.c stuff. After all, if the
> > original string is 100% guaranteed to be in UTF-8, the decoding is
> > almost trivial.
>
> It's supposedly guaranteed, but some input method modules break that
> guarantee.
And what do we want to do with those invalid UTF-8 sequences? The way
you did it will produce raw bytes for them -- is that really TRT in
this case?
In any case, at the very least consider using decode_string_utf_8
instead of consing a Lisp string and then using the "usual" decoding
stuff -- decode_string_utf_8 will cons only one string.
next prev parent reply other threads:[~2022-02-19 12:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-19 9:35 master 02bca34: Utilize new string decoding feature in GTK native input Eli Zaretskii
2022-02-19 10:09 ` Po Lu
2022-02-19 12:36 ` Eli Zaretskii [this message]
2022-02-19 12:49 ` Po Lu
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=838ru7yqw4.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=luangruo@yahoo.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).