duanhan4763 2014-07-23 22:27
浏览 50

Go-来自电子邮件的故障安全字符集

I have a bunch of emails that I decided to process in Go. Go parse everything (headers, multipart) very well.

How do I convert all emails text to UTF-8?

I read encoding name from Content-Type field and parse it with mime.ParseMediaType

I believe some emails may have bugs in encodings. e.g. wrong encoding or multiple encodings in single body.

So if there is single wrong character but 99% of text is readable. I wish to be able to read it.

PS

There are libs in go to work with charset. https://godoc.org/code.google.com/p/go.text/encoding and a set of iconv wrappers like https://github.com/djimenez/iconv-go

I think first lacks encodings and it does give decoder by encoding name. I am not sure sure that I know all synonyms of encodings. e.g. UTF-8 and utf8 are same encoding. Windows-1251 and CP-1251 are same also.

Second is iconv wrapper. Go is secure language and that is why I wish to do that in Go. There is no buffer overflow. But iconv is written in C and is less secure. I do

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值