File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ func StringToSlug(input string) string {
6060
6161// CountNumberCharacters count number of Characters including spaces. 
6262func  CountNumberCharacters (input  string ) string  {
63- 	return  fmt .Sprintf ("%d" , len (input ))
63+ 	return  fmt .Sprintf ("%d" , len ([] rune ( input ) ))
6464}
6565
6666// CountWords count number of words in string. 
Original file line number Diff line number Diff line change @@ -18,12 +18,17 @@ func TestCountNumberCharacters(t *testing.T) {
1818		}, {
1919			name : "Emoji" ,
2020			args : args {input : "😃😇🙃🙂😉😌😙😗🇮🇳" },
21- 			want : "40 " ,
21+ 			want : "10 " ,
2222		}, {
2323			name : "Multi line string" ,
2424			args : args {input : "123345\n abcd\n 456\n 123\n abc\n 567\n 7890" },
2525			want : "32" ,
2626		},
27+ 		{
28+ 			name : "Double-byte characters" ,
29+ 			args : args {input : "你好" },
30+ 			want : "2" ,
31+ 		},
2732	}
2833	for  _ , tt  :=  range  tests  {
2934		t .Run (tt .name , func (t  * testing.T ) {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments