读取unicode格式的字符串. [英] Reading a string in unicode format.

查看:125
本文介绍了读取unicode格式的字符串.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在SQL Server 2008中有一个表格,其中包含各种格式的字符串,例如ASCII,UTF-8等.我需要以unicode格式读取此字符串.

是否有任何直接查询,例如collat​​e ...或其他解决方案.

请分享您的解决方案.

Reagrds,
Sachin

Hello,

I have a table in SQL Server 2008 which contains string in various format for e.g. ASCII,UTF-8 etc.I need to read this string in unicode format.

Is there any direct query like collate... or anything else to solve this.

Please share your solution.

Reagrds,
Sachin

推荐答案

这取决于您的数据在SQL Server中的存储方式.所有unicode数据必须存储在数据类型为N(type)的列中,例如nvarchar,ntext,nchar

查看MSDN文档:

http://msdn.microsoft.com/en-us/library/aa933104 (v = sql.80).aspx [
That depends on how your data is stored in SQL Server. All unicode data must be stored in columns with datatype N(type) e.g. nvarchar, ntext, nchar

Look at MSDN documentation:

http://msdn.microsoft.com/en-us/library/aa933104(v=sql.80).aspx[^]


C#(通常是.Net)透明地处理unicode字符串,除非您有特殊要求,否则您无需做任何特殊的事情应用程序需要使用特定的编码来读取/写入文件.

默认情况下,C#中的字符串为Unicode.试试
C# (and .Net in general) handle unicode strings transparently, you won''t have to do anything special unless your application needs to read/write files with specific encodings.

Strings in C# are Unicode by default. Try
string converted = Encoding.Unicode.GetString(data);


其中data是一个包含您的Unicode数据的byte []数组.如果您的数据是高位优先的,则可以尝试


where data is a byte[] array containing your Unicode data. If your data is big endian, you can try

string converted = Encoding.BigEndianUnicode.GetString(data);


看看类似的讨论;
C#读取Unicode [ Unicode& C# [ ^ ]


Have a look on similar discussions;
C# read unicode[^]
Unicode & C#[^]


这篇关于读取unicode格式的字符串.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆