public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "trashgod at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug ada/95953] New: UTF Convert for UTF_16 to UTF_8 fails for values in U+10000 to U+10FFFF. Date: Mon, 29 Jun 2020 02:11:09 +0000 [thread overview] Message-ID: <bug-95953-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95953 Bug ID: 95953 Summary: UTF Convert for UTF_16 to UTF_8 fails for values in U+10000 to U+10FFFF. Product: gcc Version: 7.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: trashgod at gmail dot com Target Milestone: --- Created attachment 48798 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48798&action=edit complete example that reproduces problem and tests fix The library function Ada.Strings.UTF_Encoding.Conversions.Convert for UTF_16 to UTF_8 fails for values in the range U+10000 to U+10FFFF. Byte three of the four byte value is malformed; yyyyyyyy only needs to be shifted _two_ places left: Result (Len + 3) := Character'Val (2#10_000000# or Shift_Left (yyyyyyyy and 2#1111#, 2) -- originally 4 or Shift_Right (xxxxxxxx, 6)); A complete example, utftest.adb, is attached and discussed here: https://stackoverflow.com/a/62605993/230513 The output shows the code point, the expected binary representation of the UTF-8 encoding, the conversion to UTF-16, the incorrect UTF-8 conversion, and the correct UTF-8 conversion. $ gcc -v …gcc version 7.3.1 20180524 (for GNAT Community 2018 20180523) (GCC) $ gnatmake utftest.adb && ./utftest gcc -c utftest.adb gnatbind -x utftest.ali gnatlink utftest.ali Codepoint: 16#1D11E# UTF-8: 4: 2#11110000# 2#10011101# 2#10000100# 2#10011110# UTF-16: 2: 2#1101100000110100# 2#1101110100011110# UTF-8: 4: 2#11110000# 2#10011101# 2#10010000# 2#10011110# UTF-8: 4: 2#11110000# 2#10011101# 2#10000100# 2#10011110# OK
next reply other threads:[~2020-06-29 2:11 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-29 2:11 trashgod at gmail dot com [this message] 2020-06-29 10:33 ` [Bug ada/95953] " charlet at gcc dot gnu.org 2020-06-29 11:55 ` charlet at gcc dot gnu.org 2020-10-16 7:37 ` cvs-commit at gcc dot gnu.org 2020-10-16 12:17 ` charlet at gcc dot gnu.org
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=bug-95953-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.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: linkBe 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).