Re: [Gnome-print] Re: [jody: [ynakai redhat com: Re: Gnumeric bug 15607]]



Noticed a very small off-by-one bug in the memory allocation:

  fromsize = strlen(fromstr);
  tosize = fromsize * 3; /* size*2 is not enough */

to:

tosize = fromsize * 3 + 1;

you need the +1 for the '\0' byte at the end of the string. If the "from"
string was 100% kanji/kana (currently, it has ASCII in it, so you won't
overflow with the current example), you'd allocate one less byte. This will
work for current Unicode, but for Unicode 3.0 to cover all one million+
characters, you'll want to multiply by four (fromsize * 4 + 1) to cover any
possible "to-UTF-8" conversion.

Other than that, nice example.

Yukihiro Nakai wrote:

> Yesterday, I wrote an additional section
>
> - How to convert strings to UTF-8
>
> I think you should see this...
>
> Thank you.
>
> On Sun, 3 Dec 2000 19:36:39 +0900
> Yukihiro Nakai <ynakai@redhat.com> wrote:
>
> >
> > Now I write a document that we can share and start discussion from.
> > Contents are:
> >
> > Quick Guide of the Multibytes for the GTK+/GNOME Developers
> >
> > - What is the multibyte and wide characters?
> > - Fontset introduction
> > - How to support the fontset in X
> > - How to support the fontset in GTK+
> > - How to support the fontset in GNOME
> > - How to set up the multibyte testing environment.
> > - Trableshooting for the multibyte environment.
> > - How to display the Japanese strings for test.
> > - How to input multibyte in GTK+/GNOME widgets.
> > - How to support XIM in your new widget.
> > - How to use VFlib with GTK+/GNOME for the beautiful glyphs.
> > - How to use FreeType with GTK+/GNOME for the beautiful glyphs.
> > - How to test the Japanese PostScript.
> > - Other important issues in multibyte world.
> > - Multibyte functions in GTK/GDK
> > - Multibyte functions in glibc/ISO C Standard
> > - Books and URLs
> >
> > How about it?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]