数据序列化与应用层协议详解
1. 数据序列化相关内容
在数据序列化方面,有多种不同的方法和技术。
首先是一段 Go 代码示例,展示了如何使用相同的编码器以两种不同的风格进行解码:
enc.Decode(dst, w.Bytes())
fmt.Printf("%11s: %s %v\n", "viaEncoding", string(dst), dst)
}
func main() {
fmt.Printf("%11s: %s %v\n", "input", string(input), input)
var wc io.WriteCloser = base64.NewEncoder(enc, &w)
wc.Write(input)
wc.Close()
fmt.Printf("%11s: %s %v\n", "ecoded", string(w.Bytes()), w.Bytes())
restoreViaDecoder()
restoreViaEncoding()
}
运行该代码会有如下输出:
| 操作 | 数据表示 | 字节数组 |
| ---- | ---- | ---- |
| input | ∞a∞ab | [226 136 158 97 226 136 158 2 97 98] |
| encoded | 4oieYeKIngJhYg|| | [52 111 105 101 89 101 75 73 110 103 74 104 89 103 124 124] |
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



