[Php-Gtk2] GtkTextView and accented letter
| From: | ThePeg | Date: | Sat, 02 Sep 2006 12:48:20 +0000 |
| Subject: | [Php-Gtk2] GtkTextView and accented letter | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-7212@lists.php.net to get a copy of this message | ||
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#a6112409
Sent from the Php - GTK - General forum at Nabble.com.