Re: [Php-Gtk2] GtkTextView and accented letter

From: Date: Fri, 01 Dec 2006 18:33:00 +0000
Subject: Re: [Php-Gtk2] GtkTextView and accented letter
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-7485@lists.php.net to get a copy of this message
ATTENZIONE ATTENTION If you need accented characters If you are using XP check the end of PHP.INI ... you must have this setting: ;;;;;;;;;;;;; ; 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. Se ; 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 = iso-8859-1 ThePeg wrote: > > Hi all, > I'm new in developing with php-gtk2 and glade. > I'm italian so my english is not very well. > > I have a problem while getting text from a GtkTextBuffer of a GtkTextView > control: if I write any accented letters or some special chars like "£" > the script crash! > With normal characters i can read and use the text as I want. > > I'll post my code: > -------------- > $txt = $app->get_widget('txt'); // $app is my glade istance. > $buff = $txt->get_buffer(); > > $text = $buff->get_text($buff->get_start_iter(), $bff->get_end_iter()); > > $dialog = new GtkMessageDialog(null, Gtk::DIALOG_MODAL, Gtk::MESSAGE_INFO, > Gtk::BUTTONS_CLOSE, $text); > $dialog->run(); > $dialog->destroy(); > -------------- > > I try to use only a GtkTextBuffer setting into it a "malicious" text like > "ThePeg è nuovo" (italian translation for: ThePeg is new) and write to a > file the text buffer content: > -------------- > $buff = new GtkTextBuffer(); > $buff->set_text("ThePeg è nuovo"); > > $text = $buff->get_text($buff->get_start_iter(), $bff->get_end_iter()); > > $f = fopen('temp.txt', 'w'); > fwrite($f, $text); > fclose($f); > -------------- > > It work fine without crash and without corrupt characters with strange > encoding.... > > I try to show a dialog with the "malicious" text instead of write it to a > file: > -------------- > $buff = new GtkTextBuffer(); > $buff->set_text("ThePeg è nuovo"); > > $text = $buff->get_text($buff->get_start_iter(), $bff->get_end_iter()); > > $dialog = new GtkMessageDialog(null, Gtk::DIALOG_MODAL, Gtk::MESSAGE_INFO, > Gtk::BUTTONS_CLOSE, $text); > $dialog->run(); > $dialog->destroy(); > -------------- > > Character "è" will be corrupted by strange encoding... > > > > > I need help! > Thanks! > -- View this message in context: http://www.nabble.com/-Php-Gtk2--GtkTextView-and-accented-letter-tf2206985.html#a7643449 Sent from the Php - GTK - General mailing list archive at Nabble.com.

« previous php.gtk.general (#7485) next »