Problem
You want to display Japanese characters in php-gtk2 on windows as shown below:
Solution
- Open php.ini (located in the folder where you installed php-gtk2).
- Scroll to the bottom. Most likely you will see one big chunk of text like this.
- Replace that chunk of text with the following:
- If you are running Japanese windows, you are all set. If you are running English windows, go to Control Panel - Regional and Language Options. Click on the Advanced Tab and make sure the Japanese language is installed.
;;;;;;;;;;;;;;;;;;;;;;; PHP-GTK extensions ;;;;;;;;;;;;;;;;;;;;;;;; Extensions written for PHP-GTK are in the format php_gtk_*.dll (Windows) or ;php_gtk_*.so (Unix), written here as a comma-separated list. The library ; files need to be in the same directory as the PHP-GTK library, along with; any other PHP extensions you are using. php-gtk.extensions = php_gtk_libglade2.dll ;;;;;;;;;;;;;; Code Page ;;;;;;;;;;;;;;; The string variables used for titles and other text values in GTK+ are; encoded in UTF-8 internally. A code page is needed so that PHP-GTK 'knows'; which character set is being used, and can convert it to UTF-8 as necessary.; If your environment uses UTF-8 already, you can set the codepage directive ; to UTF-8 to skip the conversions.; The default codepage setting in PHP-GTK 2 is ISO-8859-1, but you can also; use either OEM (e.g. 850) or Windows Code Pages (e.g. CP1250) here, so; long as the encoding format you choose is capable of iconv conversion. See; http://www.microsoft.com/globaldev/reference/cphome.mspx for a list of; the code pages and character sets that are supported on Windows systems.php-gtk.codepage = CP1250
; Local Variables:
; tab-width: 4
; End:
; Local Variables:
; tab-width: 4
; End:
;;;;;;;;;;;;;
; Code Page ;
;;;;;;;;;;;;;
; Japanese
php-gtk.codepage = CP936
; note: if CP936 doesn't work, try CP932
; Code Page ;
;;;;;;;;;;;;;
; Japanese
php-gtk.codepage = CP936
; note: if CP936 doesn't work, try CP932
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 | <?php $window = new GtkWindow(); $window->set_size_request(240, 120); $window->connect_simple('destroy', array('Gtk','main_quit')); $label = new GtkLabel("php-gtk2 ÈÕ±¾ÕZ¤â¤Ç¤¤Þ¤¹!"); // note 1 $label->modify_font(new PangoFontDescription('ms gothic 10')); // note 2 $window->add($label); $window->show_all(); Gtk::main(); ?> |
Output
As shown above.Explanation
- You can mix Japanese characters freely with English characters.
- If you are displaying Japanese characters on a Japanese windows, you do not need this line. However, if you are using English windows, you need this line to display Japanese characters correctly.
Related Links
- How to display non English characters in php gtk2 - Part 1 - simplied Chinese on windows?
- How to display non English characters in php gtk2 - Part 2 - traditional Chinese on windows?
- How to display non English characters in php gtk2 - Part 3 - simplied Chinese on linux?
- How to display non English characters in php gtk2 - Part 4 - traditional Chinese on linux?
- How to display non English characters in php gtk2 - Part 6 - Cyrillic characters on linux?
Read more...