Home / howto / chinese 
Edit  Rename  Undo  Refresh   
fr  de  es  it  nl  pl  pt  pt_BR  mk  sq  ca  ar  fa  vi  ja  ru  zh  zh_TW  eo 
Documentation
History  
How To Display a Chinese Character - History
08/11/2006 08:02:18 - gambas
If you need to display a chinese character, or any other Unicode character,      If you need to display a chinese character, or any other Unicode character,   
now you can use the [../../comp/gb/string].[/comp/gb/string/chr] method.         now you can use the [/comp/gb/string/chr|String.Chr] method.                   
                                                                                                                                                               
{seealso                                                                         {seealso                                                                      
[/def/utf8]                                                                      [/def/utf8]                                                                   
..............................................................................   ..............................................................................
08/11/2006 08:02:03 - gambas
{example                                                                         If you need to display a chinese character, or any other Unicode character,    
                                                                                 now you can use the [../../comp/gb/string].[/comp/gb/string/chr] method.       
PUBLIC SUB Button4_Click()                                                                                                                                     
DIM i AS Integer                                                                                                                                               
DIM k AS Integer                                                                                                                                               
DIM m AS Integer                                                                                                                                               
DIM c[7] AS Integer                                                                                                                                            
DIM s AS String                                                                                                                                                
                                                                                                                                                               
s = ""                                                                                                                                                         
i = 20320 ' Code for the ni character in HTML = &20320;                                                                                                        
k = 0                                                                                                                                                          
m = 0                                                                                                                                                          
IF i \< \&H00000080\& THEN                                                                                                                                     
  c[0] = i + 0                                                                                                                                                 
  k = 1                                                                                                                                                        
  m = 0                                                                                                                                                        
ELSE                                                                                                                                                           
  IF i \< \&H00000800\& THEN                                                                                                                                   
    m = &HC0                                                                                                                                                   
  ELSE                                                                                                                                                         
    IF i \< \&H00010000\& THEN                                                                                                                                 
      m = \&HE0                                                                                                                                                
    ENDIF                                                                                                                                                      
  ENDIF                                                                                                                                                        
  c[k] = i MOD 64                                                                                                                                              
  k = k + 1                                                                                                                                                    
  i = i \ 64                                                                                                                                                   
  WHILE i \> 0                                                                                                                                                 
    c[k] = i MOD 64                                                                                                                                            
    k = k + 1                                                                                                                                                  
    i = i \ 64                                                                                                                                                 
  WEND                                                                                                                                                         
ENDIF                                                                                                                                                          
                                                                                                                                                               
k = k - 1                                                                                                                                                      
s = s \& Chr$(c[k] + m)                                                                                                                                        
WHILE k > 0                                                                                                                                                    
  k = k - 1                                                                                                                                                    
  s = s \& Chr$(c[k] + 128)                                                                                                                                    
WEND                                                                                                                                                           
                                                                                                                                                               
' The character is now coded as a three byte UTF-8 Code                                                                                                        
                                                                                                                                                               
TextBox1.Text = s                                                                                                                                              
                                                                                                                                                               
END                                                                                                                                                            
}                                                                                                                                                              
                                                                                                                                                               
{seealso                                                                         {seealso                                                                      
[/def/utf8]                                                                      [/def/utf8]                                                                   
..............................................................................   ..............................................................................
04/20/2006 12:00:50 - hj.herbert
Creation