In the version of glib we currently use g_utf8_validate rejects strings
containing the non-characters U+FFFE and U+FFFF. This was marked as a
bug and resolved (see https://bugzilla.gnome.org/show_bug.cgi?id=694669)
but until that is released we need a workaround. Our internal UTF-8
validation routine accepts these characters as valid so use that
instead.
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
bool
Validate(const Glib::ustring& s) // IN
{
- bool isValid = s.validate();
+ bool isValid = Unicode_IsBufferValid(s.c_str(), s.bytes(),
+ STRING_ENCODING_UTF8);
if (!isValid) {
- char *escaped = Unicode_EscapeBuffer(s.c_str(), -1, STRING_ENCODING_UTF8);
+ char *escaped = Unicode_EscapeBuffer(s.c_str(), s.bytes(),
+ STRING_ENCODING_UTF8);
Warning("Invalid UTF-8 string: \"%s\"\n", escaped);
free(escaped);
}