redis存储中文UTF-8编码

set "24000" "{\"vid\":24000,\"duration\":98,\"category\":[\"生活百科\"],\"channel\":[\"生活百科\"],\"vchannel\":[\"1029\"],\"title\":\"上班族经常趴桌子上午睡后果很严重!危害身体健康,得不偿失\"}"

其中value是utf-8方式编码

则从redis读出来的是utf-8编码。

get "24000"
"{\"vid\":24000,\"duration\":98,\"category\":[\"\xe7\x94\x9f\xe6\xb4\xbb\xe7\x99\xbe\xe7\xa7\x91\"],\"channel\":[\"\xe7\x94\x9f\xe6\xb4\xbb\xe7\x99\xbe\xe7\xa7\x91\"],\"vchannel\":[\"1029\"],\"title\":\"\xe4\xb8\x8a\xe7\x8f\xad\xe6\x97\x8f\xe7\xbb\x8f\xe5\xb8\xb8\xe8\xb6\xb4\xe6\xa1\x8c\xe5\xad\x90\xe4\xb8\x8a\xe5\x8d\x88\xe7\x9d\xa1\xe5\x90\x8e\xe6\x9e\x9c\xe5\xbe\x88\xe4\xb8\xa5\xe9\x87\x8d\xef\xbc\x81\xe5\x8d\xb1\xe5\xae\xb3\xe8\xba\xab\xe4\xbd\x93\xe5\x81\xa5\xe5\xba\xb7\xef\xbc\x8c\xe5\xbe\x97\xe4\xb8\x8d\xe5\x81\xbf\xe5\xa4\xb1\"}"

用Nodejs验证一下编码:

[root@dev ~]# node
> Buffer.from('生活百科','utf-8');
<Buffer e7 94 9f e6 b4 bb e7 99 be e7 a7 91>
发布了51 篇原创文章 · 获赞 3 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/pengpengzhou/article/details/101362146
今日推荐