From a6fed64abcc079877b33804420c666b867b50987 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 03 Aug 2008 20:00:25 +0000 Subject: Handle lone high surrogates gracefully. 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 . diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index e6dcc31..e05aca4 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)); }