Skip to content

Commit

Permalink
Merge pull request #1 from spiegel-im-spiegel/refactoring
Browse files Browse the repository at this point in the history
Fix character width conversion
  • Loading branch information
spiegel-im-spiegel authored Sep 11, 2021
2 parents a1ac0e4 + 4a56c95 commit 7eb9c8a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func ExampleConvert() {
s := "マツエ テッペイ めっちゃほりでぃ ナンバかげつで まんざい みるんだょっ"
s := "マツエ テッペイ めっちゃほりでぃ ナンバかげつで まんざい みるんだょっ"
fmt.Println(krconv.Convert(s))
//Output:
//matsue teppei metchahoridei nambakagetsude manzai mirundayotsu
Expand Down
26 changes: 26 additions & 0 deletions width/norm-kana.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@ package width
import "strings"

var normKatakanaMap = map[string]string{
string([]rune{'が'}): string([]rune{'か', 0x3099}),
string([]rune{'ぎ'}): string([]rune{'き', 0x3099}),
string([]rune{'ぐ'}): string([]rune{'く', 0x3099}),
string([]rune{'げ'}): string([]rune{'け', 0x3099}),
string([]rune{'ご'}): string([]rune{'こ', 0x3099}),
string([]rune{'ざ'}): string([]rune{'さ', 0x3099}),
string([]rune{'じ'}): string([]rune{'し', 0x3099}),
string([]rune{'ず'}): string([]rune{'す', 0x3099}),
string([]rune{'ぜ'}): string([]rune{'せ', 0x3099}),
string([]rune{'ぞ'}): string([]rune{'そ', 0x3099}),
string([]rune{'だ'}): string([]rune{'た', 0x3099}),
string([]rune{'ぢ'}): string([]rune{'ち', 0x3099}),
string([]rune{'づ'}): string([]rune{'つ', 0x3099}),
string([]rune{'で'}): string([]rune{'て', 0x3099}),
string([]rune{'ど'}): string([]rune{'と', 0x3099}),
string([]rune{'ば'}): string([]rune{'は', 0x3099}),
string([]rune{'び'}): string([]rune{'ひ', 0x3099}),
string([]rune{'ぶ'}): string([]rune{'ふ', 0x3099}),
string([]rune{'べ'}): string([]rune{'へ', 0x3099}),
string([]rune{'ぼ'}): string([]rune{'ほ', 0x3099}),
string([]rune{'ぱ'}): string([]rune{'は', 0x309a}),
string([]rune{'ぴ'}): string([]rune{'ひ', 0x309a}),
string([]rune{'ぷ'}): string([]rune{'ふ', 0x309a}),
string([]rune{'ぺ'}): string([]rune{'へ', 0x309a}),
string([]rune{'ぽ'}): string([]rune{'ほ', 0x309a}),
string([]rune{'ゔ'}): string([]rune{'う', 0x3099}),
string([]rune{'ガ'}): string([]rune{'カ', 0x3099}),
string([]rune{'ギ'}): string([]rune{'キ', 0x3099}),
string([]rune{'グ'}): string([]rune{'ク', 0x3099}),
Expand Down

0 comments on commit 7eb9c8a

Please sign in to comment.