From: Bruno Haible Date: Sun, 3 Aug 2008 20:00:25 +0000 (+0000) Subject: Handle lone high surrogates gracefully. X-Git-Tag: v0.18~391 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6fed64abcc079877b33804420c666b867b50987;p=thirdparty%2Fgettext.git Handle lone high surrogates gracefully. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 9e0d17243..c7e1aef1e 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,10 @@ +2008-08-03 Bruno Haible + + * x-python.c (mixed_string_buffer_append): Replace a lone high + surrogate with U+FFFD. + Reported by Yann + via Santiago Vila . + 2008-07-19 Bruno Haible * gnu/gettext/GetURL.java: Don't output anything to standard error. diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index e6dcc3190..e05aca416 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -930,6 +930,11 @@ mixed_string_buffer_append (struct mixed_string_buffer *bp, int c) if (c >= UNICODE (0xd800) && c < UNICODE (0xdc00)) bp->utf16_surr = UNICODE_VALUE (c); + else if (c >= UNICODE (0xdc00) && c < UNICODE (0xe000)) + { + /* A half surrogate is invalid, therefore use U+FFFD instead. */ + mixed_string_buffer_append_unicode (bp, 0xfffd); + } else mixed_string_buffer_append_unicode (bp, UNICODE_VALUE (c)); }