[英]How convert unicode string from database to utf-string in Go?
String is stored in database as unicode "\е\о ..." (table's encoding is UTF-8). 字符串以Unicode“ \\ u0435 \\ u043e ...”(表的编码为UTF-8)存储在数据库中。
After selecting from database and printing: 从数据库中选择并打印后:
log.Println(str) log.Println(str)
OUT: \е\о... OUT:\\ u0435 \\ u043e ...
How can I transform this string to utf presentation? 如何将该字符串转换为utf演示文稿?
To decode the string you have, you can do: 要解码您拥有的字符串,您可以执行以下操作:
import "net/url"
...
url.QueryUnescape("\u0435\u043e")
But I think there's a misconfiguration of your database or connection parameters, as this should be handled automatically. 但是我认为您的数据库或连接参数配置有误,因为这应该自动处理。 This is not utf-8 BTW. 这不是utf-8 BTW。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.