transform.Stringを使う方法がネットで記載が少なかったので記載。
func Utf8ToSjis(str string) (string, error) {
sjisEnc := japanese.ShiftJIS.NewEncoder()
sjisStr, _, err := transform.String(sjisEnc, str)
if err != nil {
return "", err
}
return sjisStr, nil
}
Go to list of users who liked
More than 1 year has passed since last update.
transform.Stringを使う方法がネットで記載が少なかったので記載。
func Utf8ToSjis(str string) (string, error) {
sjisEnc := japanese.ShiftJIS.NewEncoder()
sjisStr, _, err := transform.String(sjisEnc, str)
if err != nil {
return "", err
}
return sjisStr, nil
}
Register as a new user and use Qiita more conveniently
Go to list of users who liked