How to write a letter - in textbuffer gtkmmTextView?

When I try to insert text in a TextBuffer TextView, CMD displays the following error:

(textEditor.exe: 696): Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion g_utf8_validate (text, len, NULL) 'failed

Source example (C ++ and gtkmm):

Glib::RefPtr<Gtk::TextBuffer> refTextBuffer = textView->get_buffer();
refTextBuffer->set_text("\xA4");            //hex ASCII
refTextBuffer->insert_at_cursor("ñ");
+3
source share
1 answer

He wants to get the value of UTF-8, and you selected something in the upper ASCII range that is not displayed on UFT-8. If you look here and then here , you need to use the value 0xC3 0xB1to get the desired effect. A quick guess for code that should work for you is ...

refTextBuffer->set_text("\xC3\xB1"); //Hex version of UTF-8 Value
+1
source

All Articles