Re: [Vala] Printing Unicode Characters




Dears,

I have made this sample and I want to post it in GNOME wiki so do you recommend any change ?
void main() {
  
  string unicode_string = "1234567890 ١٢٣٤٥٦٧٨٩۰ ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 
أبتةثجحخدذرزسشصضطظعغفقكلمنهوي";
  
  for (weak string s = unicode_string; s.get_char ()!=0 ; s = s.next_char ()) {
  
    unichar unicode_character = s.get_char ();
    
    UnicodeType unicode_character_type = unicode_character.type ();
    
    switch (unicode_character_type) {
      
      case unicode_character_type.UPPERCASE_LETTER:
        stderr.printf("'%s' is UPPERCASE_LETTER\n",new StringBuilder().append_unichar(unicode_character).str);
        break;
      
      case unicode_character_type.LOWERCASE_LETTER:
        stderr.printf("'%s' is LOWERCASE_LETTER\n",new StringBuilder().append_unichar(unicode_character).str);
        break;
      
      case unicode_character_type.OTHER_LETTER:
        stderr.printf("'%s' is OTHER_LETTER\n",new StringBuilder().append_unichar(unicode_character).str);
        break;
        
      case unicode_character_type.DECIMAL_NUMBER:
        stderr.printf("'%s' is OTHER_NUMBER\n",new StringBuilder().append_unichar(unicode_character).str);
        break;
      
      case unicode_character_type.SPACE_SEPARATOR:
        stderr.printf("'%s' is SPACE_SEPARATOR\n",new StringBuilder().append_unichar(unicode_character).str);
        break;          
    }                   
  }
}

Best regards,

Date: Mon, 30 Nov 2009 18:58:44 +0100
From: scumm_fredo gmx net
To: vala-list gnome org
Subject: Re: [Vala] Printing Unicode Characters

Emad Al-Bloushi wrote:
Dears,

I would like to print unichar via stdout.printf how can I do that ?

Best regards,

The GLib documentation mentions 'g_utf32_to_utf8()' to print values of
gunichar to text:

http://library.gnome.org/devel/glib/stable/glib-Unicode-Manipulation.html#gunichar

However, this function does not exist and two weeks ago the
documentation was updated to suggest the use of 'g_ucs4_to_utf8()':

http://mail.gnome.org/archives/svn-commits-list/2009-November/msg03833.html

This method does not seem to be bound by Vala at the moment. Maybe
'unichar' should have 'to_string()' helper method in 'glib-2.0.vapi'.


Best regards,

Frederik

_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
                                          
_________________________________________________________________
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010


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