我有一些数据,我认为是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.
更多推荐
发布评论