1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【備忘録】Golangで半角全角の変換を実施する。

Posted at

対応

表題通り、Golangで半角全角の変換を実施する記事です。カタカナは半角→全角、英数字は全角→半角に変換。

main.go
package main

import (
	"fmt"

	"golang.org/x/text/width"
)
func main(){
	targetString := "ABC123アイウABC123アイウ"
	fmt.Println("変換前", targetString)
	fmt.Println("変換後", width.Fold.String(targetString))
}
実行結果
~/go/src/jikken$ go run main.go
変換前 ABC123アイウABC123アイウ
変換後 ABC123アイウABC123アイウ
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?