Problem displaying Japanese Text in GtkEntry/GtkTextView



Hello,

I have written a small GTK program (attached below), which is supposed
to display some japanese text in a GtkEntry and GtkTextView.  The text
is UTF8, and I have extracted the UTF8 values from an application that
contained some valid UTF8 japanese text.

The problem is that when I run this program on Solaris or AIX (with
GTK 2.0.9) the japanese text is not shown correctly (it either shows
blank spaces or boxes).  On Linux (with GTK 2.4) it shows the japanese
text correctly.

Is there a way to get this working on Solaris or AIX too?  Do I need
to install some fonts or set some environment variables?  Is the
environment variable such as GTK_RC_FILES or GTK2_RC_FILES required to
be set here?

Thanks a lot.
Gaurav

-----------------
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>

int main( int   argc, char *argv[] )
{

        GtkWidget *window;
        GtkWidget *vbox, *hbox;
        GtkWidget *entry1;
        GtkWidget *textView;
        char buffer[400] = {0xe5, 0xa5, 0x94, 0xe6, 0xb5, 0x81, 0xe5,
0x88, 0xb0, 0xe6, 0xb5, 0xb7, 0xe4, 0xb8, 0x8d, 0xe5, 0xa4, 0x8d, 0};
        int i = 0;
        GtkTextBuffer *tBuf = NULL;

        gtk_init (&argc, &argv);

        /* create a new window */
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100);
        gtk_window_set_title (GTK_WINDOW (window), "GTK Entry");
        g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK
(gtk_main_quit), NULL);
        g_signal_connect_swapped (G_OBJECT (window), "delete_event",
G_CALLBACK (gtk_widget_destroy), G_OBJECT (window));

        vbox = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (window), vbox);
        gtk_widget_show (vbox);

        entry1 = gtk_entry_new();
        gtk_box_pack_start (GTK_BOX (vbox), entry1, TRUE, TRUE, 0);
        gtk_widget_show (entry1);

        textView = gtk_text_view_new();
        gtk_box_pack_start (GTK_BOX (vbox), textView, TRUE, TRUE, 0);
        gtk_widget_show (textView);

        gtk_entry_set_text(GTK_ENTRY(entry1), buffer);

        tBuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView));
        gtk_text_buffer_set_text(tBuf, buffer, strlen(buffer));


        hbox = gtk_hbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (vbox), hbox);
        gtk_widget_show (hbox);

        gtk_widget_show (window);

        gtk_main();

        return 0;
}



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