[cairo] Unicode error causing Cairo to crash.
Jason Dorje Short
jdorje at users.sf.net
Tue Apr 26 14:38:18 PDT 2005
Bill Spitzak wrote:
> Owen Taylor wrote:
>> cairo_text_extents() takes a UTF-8 string ... for anything > 256,
>> what you are putting into 'c' isn't valid UTF-8 character.
>> So, it shouldn't work. But it shouldn't crash either ... if it does,
>> file a bug.
> Can we *please* make Cairo (and Pango or any other interface) draw
> illegal parts of UTF-8 as though the bytes are individual Unicode
> characters? This makes converting existing API's to UTF-8 trivial and
> would greatly encourage I18N. I have never seen (and I challenge anybody
> to come up with) an ISO-8859-1 text in any language that does not draw
> correctly when this is done.
You want invalid utf-8 characters to be drawn as if they were latin1?
Of course that will make latin1 strings draw correctly (except for ones
that happen to actually be valid utf-8). The problem is it will
encourage sloppy handling of charsets. Programs that use latin1 usually
do so without thinking, and will fail when someone tries to use
non-latin1 characters (e.g. by using latin2).
That said, it might not be hard to let the caller tell Cairo the charset
that is to be used. It is easy enough to use iconv internally to
convert from an arbitrary charset into unicode (UCS-32) which can be
passed to freetype. (I don't know how the other font backends would
handle it; conversion to a non-universal charset could potentially
require transliteration which is not well supported.)
I'd strongly encourage using iconv rather than bitfield manipulations
for changing between charsets.
More information about the cairo