bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: jkjdll@w3.org
To: bug-gnulib@gnu.org
Subject: Question about C sscanf and unicode
Date: Mon, 14 Sep 2020 19:58:47 +0200	[thread overview]
Message-ID: <20200914175847.GA13143@w3.org> (raw)

Hi,

I am a contributor to an mail hypertext archiving system called
hypermail [1], which is written in C.

Recently a bug was raised that one of its parsers had problems
when the input string had a nbsp. As you may imagine from my subject,
this is because that parser uses sscanf and the nbsp corresponds
to UTF-8 U+00A0 character:

  urlscan = sscanf(inputp, "%255[^] )<>\"\'\n[\t\\]", urlbuff);

o you know if there's an sscanf function that is UTF-8 aware?
Or, if it doesn't exist, an alternative method to be able to solve
this issue? For the moment I see two possibilities:

- As the code is already using PCRE, replace all space chars by the
  simple 0x20, temporarily, while seeing if we can replace the sscanf
  eventually by regexps.

- Convert the input string to wchar and use swscanf instead.

If you have any input on the above, I'd appreciate it very much.

Thank you in advance,

--josé

[1] https://github.com/hypermail-project/hypermail


             reply	other threads:[~2020-09-14 18:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14 17:58 jkjdll [this message]
2020-09-14 19:45 ` Question about C sscanf and unicode Bruno Haible

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://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=20200914175847.GA13143@w3.org \
    --to=jkjdll@w3.org \
    --cc=bug-gnulib@gnu.org \
    /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).