我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何在Go中将unicode字符串从数据库转换为utf字符串?

String is stored in database as unicode "\u0435\u043e ..." (table's encoding is UTF-8).

After selecting from database and printing:

log.Println(str)

OUT: \u0435\u043e...

How can I transform this string to utf presentation?

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.

近期文章

  • 如何在管道中同步goroutines
  • os。使用Go在AppEngine上打开
  • 使用用户名或电子邮件地址登录
  • 中间件将针对每个请求执行,而无需指定安装路径
  • 如何仅使用消息ID确认Rabbitmq消息(在Go中)?
  • 创建ObjectId与让DB创建它
  • 发送SIGTSTP会暂停整个程序
  • API身份验证混乱
  • 在golang中是否可以接受优美的封闭式并发模式?
  • Go Lang RESTful API无法使用JSON [重复]
  • 文字/模​​板:“无法使用0个结果调用方法/函数。”
  • 如何在Go中同步可变数量的频道?
  • 在库中使用外部依赖关系
  • 如何在时间中将nsec设置为零时间键入的值
  • 去选择频道并收集结果
  • MessageImpl不实现Message
  • golang下载文件而不是html页面
  • 在Fedora中设置并导出了GOPATH和GOBIN,但仍未安装程序
  • 系统的session满了?不知道原因
  • 使用robotframework-ride运行脚本时,卡住且不报错。

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华