SQL Server如何将这些Unicode字符存储到VARCHAR(MAX)而不是NVARCHAR(MAX)的列中(How does SQL Server store these Unicode c

编程入门 行业动态 更新时间:2024-10-10 02:16:53
SQL Server如何将这些Unicode字符存储到VARCHAR(MAX)而不是NVARCHAR(MAX)的列中(How does SQL Server store these Unicode characters into a column that is VARCHAR(MAX) and not NVARCHAR(MAX))

我有一些数据,我认为是Unicode,并看到当我将它存储到我的数据库列( VARCHAR(MAX)数据类型VARCHAR(MAX)时会发生什么。

这是来源,来自文件UTF-8 ......

looking for that ‘X’ and • 3 large bedrooms with 2 ensuites and • Main bedroom with ensuite & surround with plantation shutters`

并使用Visual Studio调试器:

=>所以2x撇号和2x子弹。

我认为如果列是NVARCHAR类型,SQL Server只能存储Unicode?

我假设我的源数据不是Unicode,因此,我完全吮吸所有这些Unicode / UTF-8的东西:(

I have some data which I believe is Unicode and seeing what happens when I store it into my database column which is of VARCHAR(MAX) datatype.

And here's the source, from the file which is UTF-8...

looking for that ‘X’ and • 3 large bedrooms with 2 ensuites and • Main bedroom with ensuite & surround with plantation shutters`

and using the Visual Studio debugger:

=> so 2x apostrophes and 2x bullets.

I thought SQL Server can only store Unicode if the column is of type NVARCHAR?

I'm assuming my source data is not Unicode and therefore, I totally suck at all this Unicode/UTF-8 stuff :(

最满意答案

我认为如果列是NVARCHAR类型,SQL Server只能存储Unicode?

那是对的。 据我所知,从你的例子来看,它不存储Unicode。 可能它存储在Windows代码页1252中编码的字节,这将是西方安装的SQL Server的默认编码。

代码页1252 恰好包含字符' , '和•映射,因此可以安全地存储这些字符。 但是走出那个有限的曲目,你会开始失去角色。

I thought SQL Server can only store Unicode if the column is of type NVARCHAR?

That's correct. As far as I can guess from your example, it is not storing Unicode. Probably it is storing bytes encoded in Windows code page 1252, which would be the default encoding for a Western install of SQL Server.

Code page 1252 happens to include mappings for characters ‘, ’ and •, so those characters can be safely stored. But step outside that limited repertoire and you'll start losing characters.

更多推荐

本文发布于:2023-08-06 22:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457315.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   而不是   字符   Unicode   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!