在golang中如何将punycode转换为unicode?_-csdn问答


本站和网页 https://ask.csdn.net/questions/1040894 的作者无关,不对其内容负责。快照谨为网络故障时之索引,不代表被搜索网站的即时页面。

在Golang中如何将punycode转换为unicode?_-CSDN问答
关注 码龄 粉丝数 原力等级 -- 被采纳 被点赞 采纳率 doulv8162
2017-07-13 14:55
浏览 145
首页
已采纳
在Golang中如何将punycode转换为unicode?
I wanna convert url f.e.:
xn--h1aaebtrh5b.xn--p1ai
-->
кисточки.рф
And of course reverse:
kremlin.ru
--->
xn--d1abbgf6aiiy.xn--p1ai
I try use
idna
package, but i can't import vendor package idna
Link
on doc:
https://godoc.org/golang.org/x/net/idna#Profile.ToUnicode
Try import:
import "golang_org/x/net/idna"
Get error:
main.go:18:8: cannot find package "golang_org/x/net/idna" in any of:
/usr/local/go/src/golang_org/x/net/idna (from $GOROOT)
/home/arseny/go/src/golang_org/x/net/idna (from $GOPATH)
Another try:
import "vendor/golang_org/x/net/idna"
Errors:
main.go:18:8: must be imported as golang_org/x/net/idna
main.go:19:2: use of vendored package not allowed
收起
写回答
好问题
提建议
追加酬金
关注问题
微信扫一扫
点击复制链接
分享
邀请回答
编辑
收藏
删除
结题
举报
(90%的用户在追加酬金后获得了解决方案)
当前问题酬金
(可追加 ¥500)
支付方式
扫码支付
加载中...
支付金额
15
提供问题酬金的用户不参与问题酬金结算和分配
支付即为同意
《付费问题酬金结算规则》
再想想
再等等
条回答
默认
最新
dsxml2169
2017-07-13 15:01
Some people say that this code work
In bash:
go get golang.org/x/net/idna
Example code go:
package main
import (
"fmt"
"golang.org/x/net/idna"
var p *idna.Profile
func main() {
// Raw Punycode has no restrictions and does no mappings.
p = idna.New()
fmt.Println(p.ToUnicode("xn--d1abbgf6aiiy.xn--p1ai"))
But i'm still hope that another way exist. I unlike to do local copy of package into $GOROOT path.
本回答被题主选为最佳回答
, 对您是否有帮助呢?
本回答被专家选为最佳回答
本回答被题主和专家选为最佳回答
解决
无用
评论
打赏
按下Enter换行,Ctrl+Enter发表内容
查看更多回答(0条)
向“C知道”追问
报告相同问题?
提交
采纳
Golang
如何将
puny
code
转换
unicode
回答 1
Some people say that this
work
go get
golang
.org/x/net/idna
Example
go:
pa
如何在
将字符串
为数组?
2017-03-25 09:12
To initialize a string slice in Go, you use s := []string{"This is a string"}.
To initialize a str
的类型
如何工作?
2018-12-24 11:55
You have several mistakes in your logic, your benchmark and your assumptions.
As for the casting,
实现
为字符串string的方法
2020-09-21 14:09
主要介绍了
为字符串string的方法,实例分析了Go语言编码
的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
我应该如何在
将切片
为字符串?
2016-03-13 20:32
回答 2
To ensure that Go doesn't keep the underlying string in memory you will have to explicitly copy it
的字符串
Unicode
2018-06-15 15:15
You are quoting from a weak, unreliable source: Go Essentials: Strings. Amongst other things, ther
将全角数字字符
为Ascii?
2016-06-05 19:27
You can use the width.Transformer of the
.org/x/text package to do the transformation but th
知识分享之
——在
码和
文的互相
函数
2022-06-06 10:06
CN華少的博客
函数 背景 知识分享之
篇是我在日常使用
时学习到的各种各样的知识的记录,将其整理出来以文章的形式分享给大家,来进行共同学习。欢迎大家进行...
初始化接口数组?
2018-09-03 12:50
回答 4
If you have to create a slice of values for passing to something that requires a slice of interfac
模板
迭代一系列数字?
2019-09-02 19:54
The template package does not support this directly.
Create a template function that returns a sl
路由
将URL作为参数传递?
http
2017-04-26 13:30
This particular behavior in Gorilla Mux can be changed by setting SkipClean to true.
router := mu
与字符串示例详解
2020-09-16 19:07
主要给大家介绍了关于
与字符串的相关资料,文
通过示例代码介绍的非常详细,对大家学习或者使用
具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
创建kafka消费者组?
2017-02-01 18:07
The consumer group is specified by the second argument of the cluster consumer "constructor". Here
判断结构体为空_如何在
检查结构是否为空?
2020-07-30 22:14
cumtb2002的博客
判断结构体为空The size of an empty structure is zero in
. Here, empty structure ... 在
, 空结构的大小为零。 在此, 空结构表示该结构
没有字段。
Eg:
例如:
Type structure_na...
为字符串_在
,如何将字符串
符文数组并返回?
2020-07-21 20:25
cuma2369的博客
为字符串In
, how to convert a string... 在
,如何将 字符串
符文数组并执行相反的方法?
Convert string s to a rune array: 将字符串s
为符文数组:
runes := []run...
没有解决我的问题,
去提问
向专家提问
向AI提问
◇ 用户帮助中心
◇《冲榜分奖金》活动下线公告 及AIGC类回答处理措施
◇ 新手如何提问
◇ 奖惩公告
悬赏问题
¥20
有关区间dp的问题求解
¥15
多电路系统共用电源的串扰问题
slam rangenet++配置
有没有研究水声通信方面的帮我改俩matlab代码
对于相关问题的求解与代码
ubuntu子系统密码忘记
信号傅里叶变换在matlab上遇到的小问题请求帮助
保护模式-系统加载-段寄存器
电脑桌面设定一个区域禁止鼠标操作
求NPF226060磁芯的详细资料