Home > database >  Essentially a nvarchar type storage UTF8 characters in confusion
Essentially a nvarchar type storage UTF8 characters in confusion

Time:10-04

最近遇到一个情况,SQLServer版本是2012,排序规则是Chinese_PRC_BIN,其中我有一个字段类型是nvarchar(MAX),程序生成了一段中文内容:"我是中国人",然后存入这个字段,但是存进去的时候发现内容变了,变成了:"鎴戞槸涓浗浜?" , a look, should according to GBK encoding format conversion is the Chinese, but my memory of this passage is utf-8,
我查到一个网站(https://www.cnblogs.com/hayden/archive/2010/12/16/1908261.html)大概意思是说nvarchar存储的是Unicode数字类型的字符,是2个字节表示,而GBK编码也是2个字节,所以我大胆的猜测是不是因为这个原因直接把"我是中国人"按照GBK的方式转成了"鎴戞槸涓浗浜?" , that if I want to let it is UTF8 encoding of "I am a Chinese, I again how to operate?

CodePudding user response:

SQL server does not support the utf8, so if you store the utf8, so will be converted to unicode, when as for conversion, it depends on your specific store operation
  • Related