GO語言"unicode"包中"SimpleFold"函數的用法及代碼示例。
用法:
func SimpleFold(r rune) rune
SimpleFold 迭代在 Unicode-defined 簡單大小寫折疊下等效的 Unicode 代碼點。在與 rune 等效的代碼點中(包括 rune 本身),SimpleFold 如果存在則返回最小的 rune > r,否則返回最小的 rune >= 0。如果 r 不是有效的 Unicode 代碼點,則 SimpleFold(r) 返回河。
例如:
SimpleFold('A') = 'a' SimpleFold('a') = 'A' SimpleFold('K') = 'k' SimpleFold('k') = '\u212A' (Kelvin symbol, K) SimpleFold('\u212A') = 'K' SimpleFold('1') = '1' SimpleFold(-2) = -2
例子:
package main
import (
"fmt"
"unicode"
)
func main() {
fmt.Printf("%#U\n", unicode.SimpleFold('A')) // 'a'
fmt.Printf("%#U\n", unicode.SimpleFold('a')) // 'A'
fmt.Printf("%#U\n", unicode.SimpleFold('K')) // 'k'
fmt.Printf("%#U\n", unicode.SimpleFold('k')) // '\u212A' (Kelvin symbol, K)
fmt.Printf("%#U\n", unicode.SimpleFold('\u212A')) // 'K'
fmt.Printf("%#U\n", unicode.SimpleFold('1')) // '1'
}
輸出:
U+0061 'a' U+0041 'A' U+006B 'k' U+212A 'K' U+004B 'K' U+0031 '1'
相關用法
- GO Sin用法及代碼示例
- GO Sinh用法及代碼示例
- GO Sign用法及代碼示例
- GO Sincos用法及代碼示例
- GO Scanner.Scan用法及代碼示例
- GO StreamWriter用法及代碼示例
- GO Split用法及代碼示例
- GO Server.Shutdown用法及代碼示例
- GO Slice用法及代碼示例
- GO StructTag.Lookup用法及代碼示例
- GO SplitAfter用法及代碼示例
- GO Sum256用法及代碼示例
- GO SectionReader用法及代碼示例
- GO Sprintf用法及代碼示例
- GO Strings用法及代碼示例
- GO SendMail用法及代碼示例
- GO StructTag用法及代碼示例
- GO Stmt用法及代碼示例
- GO Sprint用法及代碼示例
- GO SpecialCase用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 SimpleFold。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。