Created
November 8, 2014 20:42
-
-
Save tenntenn/7e559d130f15a442edaf to your computer and use it in GitHub Desktop.
ひらがなかカタカナなのか判定したい #golang ref: http://qiita.com/tenntenn/items/b0fa4dcd5e2f54a373aa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func In(r rune, ranges ...*RangeTable) bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"unicode" | |
) | |
func main() { | |
for _, r := range "あいうえおアイウエオアイウエオ" { | |
fmt.Println(string(r), "is Hiragana", unicode.In(r, unicode.Hiragana)) | |
fmt.Println(string(r), "is Katakana", unicode.In(r, unicode.Katakana)) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ToLowerSpecial(_case unicode.SpecialCase, s string) string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CaseRange struct { | |
Lo uint32 | |
Hi uint32 | |
Delta d | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type d [MaxCase]rune |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unicode.CaseRange{ | |
Lo: ..., | |
Hi: ..., | |
Delta: [unicode.MaxCase]rune{0, 0x131 - 0x49, 0}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment