buglibiconv - Bugs: bug #39238, Fixing bad utf8.


bug #39238: Fixing bad utf8.

Submitted by:  None
Submitted on:  Wed 12 Jun 2013 11:04:32 AM UTC  
Category:  Converters Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  Bruno Haible <haible>
Open/Closed:  Closed

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Fri 18 Nov 2016 08:47:41 AM UTC, comment #3:

Sorry, I must have been confused since which implementation is used varies across Linux distributions. Good to see some activity here!

Milan Bouchet-Valat <nalimilan>
Thu 17 Nov 2016 11:14:05 PM UTC, comment #2:

There are two iconv implementations in GNU: The one in GNU libc and the one in GNU libiconv. They operate in similar ways, but they are a different codebase.

As can be seen from your command 'iconv --from=UTF-8 --to=UTF-8 -c' (long options), you must be using the GNU libc one.

For GNU libc, the behaviour you reported is equivalent to https://sourceware.org/bugzilla/show_bug.cgi?id=2373

For GNU libiconv, the behaviour you reported has now been corrected: http://git.savannah.gnu.org/gitweb/?p=libiconv.git;a=commit;h=0a04404c90d6a725b8b6bbcd65e10c5fcf5993e9

Thank you for the report.

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Tue 10 Sep 2013 10:02:09 AM UTC, comment #1:

I am experiencing a similar issue: the invalid sequence \U3e3965 is not correctly removed. This is a problem since PCRE does not accept this character and generates an error.

# Correctly removed
$ echo -e "\xff" | iconv --from=UTF-8 --to=UTF-8 -c

# Not removed as it should
$ echo -e "\xf8\x8f\xa3\xa5\xa5" | iconv --from=UTF-8 --to=UTF-8 -c

Milan Bouchet-Valat <nalimilan>
Wed 12 Jun 2013 11:04:32 AM UTC, original submission:


I'm trying to clean utf8 encoded buffer using iconv and remove all invalid utf8 code points(below is my code snippet)

iconv_t conv = iconv_open("UTF-8//IGNORE","UTF-8");
iconvctl(conv, ICONV_SET_DISCARD_ILSEQ, &flag);
iconv(conv, &inbuf, &len, &outbuf, &outlen);

I noticed that it is not able to remove code points in range of 0xD800-0xDfff (surrogate pairs) even though these are not valid utf8 code points.

Other invalid code points like beyond 0x10FFFF and wrong/broken utf8 byte sequence is are cleaned successfully.

What might be the issue here?




(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by nalimilan (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    Wed 23 Nov 2016 11:55:25 PM UTC haible CategoryNone => Converters
    Thu 17 Nov 2016 11:14:05 PM UTC haible StatusNone => Fixed
        Assigned toNone => haible
        Open/ClosedOpen => Closed

    Back to the top

    Powered by Savane 3.3