Re: GtkTextView to display a bullet character



On Wed, 2004-10-20 at 00:51, Siva Rami Reddy G wrote:
> Hi,
>  
> I am trying to display a bullet character on to a GtkTextView. 
>  
> It is giving me the error that [Invalid UTF8] character specified.
>  
> The ASCII value of bullet character is 0x95 and the equivalent UTF8
> value is 0x25CF

To begin, 0x95 is not ASCII because it is greater than 0x7f. The UTF-8
equivalent of any ASCII value is merely the ASCII value.

Also, 0x95 is a control code in Unicode ("MESSAGE WAITING"); the UTF-8
encoding is <0xc2 0x95>.

Finally, be careful how you express multibyte values when endianness
matters; 0x25cf could be <0x25 0xcf> or <0xcf 0x25>. No matter in your
case, neither is a valid UTF-8 sequence.

Perhaps you want the Unicode character at 0xb7 ("MIDDLE DOT"), which is
<0xc2 0xb7> in UTF-8. Other possibilities:

  Unicode 0x2022 ("BULLET"), <0xe2 0x80 0xa2> in UTF-8
  Unicode 0x2024 ("ONE DOT LEADER"), <0xe2 0x80 0xa4>
  Unicode 0x2219 ("BULLET OPERATOR"), <0xe2 0x88 0x99>

There are, undoubtedly, many others.

> Can you please suggest me where I am going wrong in displaying the
> character.
> I did not find a proper api to convert a character from ASCII to UTF8
> either.

Like I said, any ASCII sequence is the same as the equivalent UTF-8
sequence, an API for that would be silly. However, various conversion
functions can be found at:

http://developer.gnome.org/doc/API/2.0/glib/glib-Unicode-Manipulation.html

You may be interested these: g_ucs4_to_utf8(), g_utf8_to_ucs4(), and
g_unichar_to_utf8().

Be patient, understanding Unicode is a long road.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]