Re: [Gnome-print] Re: [jody: [ynakai redhat com: Re: Gnumeric bug 15607]]
- From: Yukihiro Nakai <ynakai redhat com>
- To: Yukihiro Nakai <ynakai redhat com>
- Cc: clahey helixcode com, lauris helixcode com, miguel helixcode com, jgoldberg home com, gnome-print helixcode com, havill redhat com
- Subject: Re: [Gnome-print] Re: [jody: [ynakai@redhat.com: Re: Gnumeric bug 15607]]
- Date: Tue, 12 Dec 2000 19:37:18 +0900
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?
- How to convert strings to UTF-8
The below function str2utf8() converts strings in the
currently selected codeset into UTF-8 strings.
To know what codeset is used in the current locale, use
nl_langinfo(CODESET). There is also iconv command and you
can see the all codesets with 'iconv --list'.
#include <stdio.h>
#include <glib.h>
#include <langinfo.h>
#include <iconv.h>
#include <string.h>
gchar* jptext = "ÆüËܸì¤Îtest"; /* This is the test strings. */
gchar* str2utf8(gchar* fromstr) {
iconv_t fd;
gchar* codeset;
gchar* fromstr_p;
gchar* tostr;
gchar* tostr_p;
size_t ret_size;
size_t fromsize;
size_t tosize;
if( fromstr == NULL || *fromstr == '\0' ) return NULL;
fromstr_p = fromstr;
fromsize = strlen(fromstr);
tosize = fromsize * 3; /* size*2 is not enough */
tostr_p = tostr = g_malloc0(sizeof(gchar)*tosize);
codeset = nl_langinfo(CODESET);
if (codeset == NULL)
codeset = g_strdup("ANSI_X3.4-1968"); /* C locale codeset */
fprintf(stderr, "%s to UTF8\n", codeset);
fd = iconv_open("UTF-8", codeset);
ret_size = iconv(fd, &fromstr_p, &fromsize, &tostr_p, &tosize);
iconv_close(fd);
return tostr;
}
int main() {
setlocale(LC_ALL, "ja_JP.eucJP");
printf("%s\n", str2utf8(jptext));
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]