Output of comparing two Japanese words is unreadable
- Dominant language
- Go
- Stars
- 4.7k
- Forks
- 243
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
When I want to compare two Japanese words and there is diff, the returned value of `Diff` method is unreadable.
## Detail
Here is an example.
```golang
func Echo() string {
return "プライベート ブランド シャツ"
}
```
test code
```golang
func TestEcho(t *testing.T) {
expected := "プライベート ブランド ジャケット"
actual := Echo()
if diff := cmp.Diff(expected, actual); diff != "" {
t.Errorf("%s result mismatch (-want, +got):\n%s", t.Name(), diff)
}
}
```
`cmp.Diff` produces
```bash
--- FAIL: TestEcho (0.00s)
main_test.go:13: TestEcho result mismatch (-want, +got):
strings.Join({
"プライベート ブランド \xe3\x82",
- "\xb8ャケット",
+ "\xb7ャツ",
}, "")
FAIL
FAIL cmpbug 0.347s
FAIL
```
the above output is not readable. I expect the following output
```bash
❯ go test ./...
--- FAIL: TestEcho (0.00s)
main_test.go:13: TestEcho result mismatch (-want, +got):
string(
"プライベート ブランド ",
- "ジャケット",
+ "シャツ",
)
FAIL
FAIL cmpbug 0.229s
FAIL
```
version info
- go: 1.19.2
- cmp: v0.5.9
Contributor guide
Assessment
This issue has not been assessed yet.