在Go的go.text中支持iso-8859-1编码。

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

Go iso-8859-1 encoding support in go.text

问题

我在我的项目中使用go.text库。
https://godoc.org/code.google.com/p/go.text/encoding

我不明白为什么它缺少iso-8859-1编码?

我知道我可以很容易地进行转码:byte -> rune -> utf8
https://stackoverflow.com/questions/6002619/unmarshal-an-iso-8859-1-xml-input-in-go

但我想知道在go.text中是否有一些以不同名称命名的iso-8859-1编码。我知道它有以下名称:

    ISO_8859-1:1987
    ISO-8859-1
    iso-ir-100
    ISO_8859-1
    latin1
    l1
    IBM819
    CP819
    csISOLatin1
英文:

I use go.text in my project
https://godoc.org/code.google.com/p/go.text/encoding

I do not understand why it is missing iso-8859-1?

I know I can easily transcode it byte -> rune -> utf8
https://stackoverflow.com/questions/6002619/unmarshal-an-iso-8859-1-xml-input-in-go

But I wonder if there is some encoding in go.text that is iso-8859-1 but named differently. I know it has following names.

    ISO_8859-1:1987
    ISO-8859-1
    iso-ir-100
    ISO_8859-1
    latin1
    l1
    IBM819
    CP819
    csISOLatin1

答案1

得分: 5

你可以在iso-8859-1的位置使用Windows1252

这种字符编码是ISO 8859-1的超集,但与IANA的ISO-8859-1不同,它在80到9F(十六进制)范围内使用可显示字符而不是控制字符。

http://en.wikipedia.org/wiki/Windows-1252

ISO-8859-1在此范围内分配了几个控制码。Windows-1252在这些码点上分配了几个字符、标点符号、算术和商业符号。

这里有一个显示差异的图表:

http://www.i18nqa.com/debug/table-iso8859-1-vs-windows-1252.html

英文:

You can use Windows1252 in place of iso-8859-1.

> This character encoding is a superset of ISO 8859-1, but differs from the IANA's ISO-8859-1 by using displayable characters rather than control characters in the 80 to 9F (hex) range

http://en.wikipedia.org/wiki/Windows-1252

>ISO-8859-1 assigns several control codes in this range. Windows-1252 has several characters, punctuation, arithmetic and business symbols assigned to these code points.

There is a chart with the differences here:

http://www.i18nqa.com/debug/table-iso8859-1-vs-windows-1252.html

huangapple
  • 本文由 发表于 2014年8月5日 00:11:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/25123017.html
匿名

发表评论

匿名网友

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

确定