dongshan1811 2017-11-15 04:30
浏览 606
已采纳

如何在Golang中获取带引号的可打印字符串

How to get a quoted printable string created according to » RFC2045, section 6.7. in golang

PHP equivalent is "quoted_printable_encode ( string $str )"

  • 写回答

1条回答 默认 最新

  • dongyuan4790 2017-11-15 06:45
    关注

    Use the standard quotedprintable package to encode the string:

    ...
    
    import (
        "bytes"
        "mime/quotedprintable"
        "github.com/pkg/errors"
    )
    
    ...
    
    func toQuotedPrintable(s string) (string, error) {
        var ac bytes.Buffer
        w := quotedprintable.NewWriter(&ac)
        _, err := w.Write([]byte(s))
        if err != nil {
            return "", errors.Wrap(err, "write")
        }
        err = w.Close()
        if err != nil {
            return "", errors.Wrap(err, "close")
        }
        return ac.String(), nil
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏