Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "code.google.com/p/go.text/unicode/norm"
- import "fmt"
- import "unicode/utf8"
- func main() {
- s := "\u0451\u0439" // ёй
- s_nfc := norm.NFC.String(s)
- s_nfd := norm.NFD.String(s)
- for _,x := range [...]string{s, s_nfc, s_nfd} {
- fmt.Printf("'%s' (%x) has %d runes\n", x, x, utf8.RuneCountInString(x))
- }
- }
- // output:
- // $ go build gonorm && ./gonorm
- // 'ёй' (d191d0b9) has 2 runes
- // 'ёй' (d191d0b9) has 2 runes
- // 'ёй' (d0b5cc88d0b8cc86) has 4 runes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement