C in Go: string ( int ( C.int ) ) returns \u000X

huangapple go评论75阅读模式
英文:

C in Go: string ( int ( C.int ) ) returns \u000X

问题

我在C语言中有一个枚举类型,我想在多个项目之间共享。

当我使用string ( int ( C.int ) )时,

我得到的是枚举中第三个元素的\u0002,我只需要得到数字2而不是\u0002。

谢谢。

英文:

I have an enum in C that I am sharing between projects.

When I use string ( int ( C.int ) )

I get \u0002 for third in enum, I just need the number in plain "2"?

Regards

答案1

得分: 9

在Go语言中,string(int(x))会生成一个包含符文(也称为Unicode点)x的字符串;string(12)不是fmt.Sprintf("%d", 12)strconv.Itoa的简写。

英文:

In Go string(int(x)) will produce a string containing the rune (aka Unicode point) x; string(12) is not a shortcut for fmt.Sprintf("%d", 12) or strconv.Itoa.

huangapple
  • 本文由 发表于 2015年1月14日 20:43:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/27943245.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定