Advertisement
Guest User

Untitled

a guest
Feb 17th, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.50 KB | None | 0 0
  1. package main
  2.  
  3. import "code.google.com/p/go.text/unicode/norm"
  4. import "fmt"
  5. import "unicode/utf8"
  6.  
  7. func main() {
  8.   s := "\u0451\u0439" // ёй
  9.   s_nfc := norm.NFC.String(s)
  10.   s_nfd := norm.NFD.String(s)
  11.   for _,x := range [...]string{s, s_nfc, s_nfd} {
  12.     fmt.Printf("'%s' (%x) has %d runes\n", x, x, utf8.RuneCountInString(x))
  13.   }
  14. }
  15.  
  16. // output:
  17. // $ go build gonorm && ./gonorm
  18. // 'ёй' (d191d0b9) has 2 runes
  19. // 'ёй' (d191d0b9) has 2 runes
  20. // 'ёй' (d0b5cc88d0b8cc86) has 4 runes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement