英文:
Given an ASCII character code, how do I encode it as UTF-8?
问题
我需要将我的生成的ASCII字符代码转换为Go语言。
我的生成的代码如下:
- 0(1-9缺失,可能无用)
- 10(11-31缺失,可能更无用)
- 32
- 33
- 34
- ...
- 124
- 125
- 126
如何将它们转换为相应的UTF-8编码字符?
英文:
I need to convert my generated ASCII character codes in Go.
My generated codes are as follows:
- 0 (1-9 are missing, probably useless)
- 10 (11-31 are missing, probably even more useless)
- 32
- 33
- 34
- ...
- 124
- 125
- 126
How do I convert them to the corresponding UTF-8-encoded characters?
答案1
得分: 1
数字值是字节。你可以直接将它们转换为字符串。
b := []byte{97,98,99,68} // abcD的ASCII码
fmt.Println(string(b))
英文:
The numeric values are the bytes. You can directly convert those to strings.
b := []byte{97,98,99,68} // The ascii codes of abcD
fmt.Println(string(b))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论