Reputation: 1231
I want to insert •
into GtkTextView widget. In Python + pyGTK this line was sufficient:
self.__textBuffer.insert_at_cursor(u'\u2022')
Because I'm rewriting my application to C i need to translate this line of code.
I was trying to do:
gtk_text_buffer_insert_at_cursor(textBuffer, "\x20\x22", 2);
But it not worked, only inserted 2 chars"*
.
How can I translate u'\u2022' from Python to C?
Upvotes: 2
Views: 341
Reputation: 7733
How can I translate u'\u2022' from Python to C?
If you are using c++ compiler to build it, and the compiler have spec c++0x or c++11 (you can specify with g++ -std=c++0x
), you can write the code like following.
gtk_text_buffer_insert_at_cursor(textbuffer, u8"\u2022", -1);
Upvotes: 1
Reputation: 400019
You need to UTF-8 encode it, since GTK+'s encoding is UTF-8.
Thus:
const char bullet_utf8[] = "\xe2\x80\xa2";
gtk_text_buffer_insert_at_cursor(textBuffer, bullet_utf8, strlen(bullet_utf8));
You can see the UTF-8 encoding of this character here, for instance.
Upvotes: 1