[cairo] Unicode error causing Cairo to crash.

Jason Dorje Short jdorje at users.sf.net
Wed Apr 27 13:13:19 PDT 2005

Bill Spitzak wrote:

> *PLEASE* make the UTF-8 drawing print one visible glyph (such as an
> error box) for each byte of misencoded UTF-8, and *continue to parse and
> print the rest of the string*. Do NOT print nothing. Do NOT truncate at
> the error. Do NOT skip the error so it's invisible. Do NOT print ASCII
> (<128) characters (for security reasons). Do NOT think the string is
> something other than UTF-8. Do NOT return an "error". NO, NO, NO, NO!!!

That seems like a good idea; it would make debugging this output much
easier.  However you should probably return an error as well (depending
on the function maybe).

I do think taking ONLY utf-8 strings is a bad idea.  I haven't looked at
the cairo API here but UCS-2 and (especially) UCS-4 are theoretically
better than UTF-8 and it would be a shame to make someone convert from
these encodings into UTF-8, only to have the cairo implementation
convert BACK into unicode to do glyph lookups.

We shouldn't fall into the Microsoft/SDL trap of calling UCS-2 "UNICODE"
however.  Seems like everyone has a different definition of "UNICODE"
and I think only the Freetype one makes sense (UNICODE = ascii, latin1,
ucs-2, ucs-4).


More information about the cairo mailing list