strings.Join with non-standard space is converting to \u strings

Let’s say I want to create a string from a slice of string containing individual Japanese words. The separator is Japanese full length space ( ). The code is as follows:

const separator = " "

func getJoinedString(words []string) string {
	joinedString := strings.Join(words, separator)

	return joinedString
}

The output I am getting

語る\u3000物語\u3000英語\u3000単語\u3000日本語\u3000語\u3000言語\u3000語りかける\u3000敬語\u3000物語る

Expected output

語る 物語 英語 単語 日本語 語 言語 語りかける 敬語 物語る

Note: For some reason, Discourse is automatically converting Japanese full length space to half length English space. Hence the code + output contains half-length English spaces.

I mean it works: Go Playground - The Go Programming Language

Wondering how you’re viewing that string, As demonstrated in the play, "\u3000" is a valid way in Go of specifying that character, wondering if this is just a product of the tool you’re using to view the string?

1 Like

Yes, you are correct. I should’ve check it properly. It seems VSCode is showing \u3000 instead o the proper character.

1 Like