Closed helloshaohua closed 3 years ago
package converter import "github.com/stretchr/testify/assert" func (e *EncoderSuite) Test_ChineseToPinYinString() { grids := []struct { in string sep string expected string }{ {in: "hello, 中国", sep: "", expected: "hello,zhongguo"}, } for _, grid := range grids { actual := ChineseToPinYinString(grid.in, grid.sep) assert.Equal(e.T(), grid.expected, actual, "has error, want:%+v, but got: %+v, resource data value of the: %+v\n", grid.expected, actual, grid.in) } }
@helloshaohua 可以通过 Fallback 参数实现。 https://pkg.go.dev/github.com/mozillazg/go-pinyin#Pinyin 中的 【Example (FallbackCustom1) 】
Fallback
好的,谢谢~