从数据集解码文本,嗯...帮助赞赏。 [英] text decoding from dataset, hmm... help appreciated.

查看:77
本文介绍了从数据集解码文本,嗯...帮助赞赏。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


这是我的问题:


我有一个SQL Server 2000 DB,其中包含各种NVarChar,NText字段

表。

由于某些愚蠢的原因,数据以UTF8

编码插入到这些字段中。


然而,当你将这些值检索到数据集和ToString()时,

一些

字符就像垃圾一样。

$ b因此,我已经开始编写一个扔掉的应用程序,它将通过

所有相关表格和字段进行解码,然后使用unicode值进行更新。


然而我有点困惑和困惑。似乎有很多类

的声音与我想要的完全一样,但是他们要么不转换为unicode

,要么他们希望数据在一个字节内阵列。试图将数据集转换为从对象到字节数组的
值导致无效的强制转换异常。


任何关于编码内容的详细信息的想法或链接都会很多

赞赏。


问候,

彼得

解决方案

Peter Row< pe ******* @ oxfordcc.co.uk>写道:

这是我的问题:

我有一个SQL Server 2000数据库,其
表中有各种NVarChar,NText字段。
对于某些人来说数据以UTF8
编码插入这些字段的愚蠢原因。


这不应该有任何可能性 - 编码根本不重要,因为

最终会在数据库中出现的是unicode字符。

但是当你将这些值检索到数据集和ToString()时,有些角色会变成垃圾。

因此我开始写一个投掷远离应用程序将通过所有相关的表格和字段进行解码,然后使用unicode值进行更新。

然而我有点困惑和困惑。似乎有很多类听起来与我想要的完全一样,但是他们要么不转换为unicode
,要么他们希望数据在字节数组中。尝试将数据集值从对象转换为字节数组会导致无效的强制转换异常。

任何关于编码内容的详细信息的想法或链接都会受到很多赞赏。




参见 http://www.pobox.com/~skeet/csharp/unicode.html

-

Jon Skeet - < ; sk *** @ pobox.com>
http://www.pobox .com / ~siget

如果回复小组,请不要给我发邮件


Peter Row< pe * ******@oxfordcc.co.uk>写道:

这是我的问题:

我有一个SQL Server 2000数据库,其
表中有各种NVarChar,NText字段。
对于某些人来说数据以UTF8
编码插入这些字段的愚蠢原因。


这不应该有任何可能性 - 编码根本不重要,因为

最终会在数据库中出现的是unicode字符。

但是当你将这些值检索到数据集和ToString()时,有些角色会变成垃圾。

因此我开始写一个投掷远离应用程序将通过所有相关的表格和字段进行解码,然后使用unicode值进行更新。

然而我有点困惑和困惑。似乎有很多类听起来与我想要的完全一样,但是他们要么不转换为unicode
,要么他们希望数据在字节数组中。尝试将数据集值从对象转换为字节数组会导致无效的强制转换异常。

任何关于编码内容的详细信息的想法或链接都会受到很多赞赏。




参见 http://www.pobox.com/~skeet/csharp/unicode.html

-

Jon Skeet - < ; sk *** @ pobox.com>
http://www.pobox .com / ~siget

如果回复小组,请不要给我发邮件


Jon Jon,

我在language.vb小组告诉Peter在这里问这个,因为专家Jon Skeet有

,我觉得你可以更好。


(现在我的建议看起来一无所获,也许我自己做,虽然我不是

当然是专家)

Cor

Hi all,

Here is my problem:

I have a SQL Server 2000 DB with various NVarChar, NText fields in its
tables.
For some stupid reason the data was inserted into these fields in UTF8
encoding.

However when you retrieve these values into a dataset and ToString() them
some
characters come out as garbage.

So therefore I have started writing a throw away app that will go through
all the
relevant tables and fields decoding and then updating with unicode values.

However I''m a bit confused and stuck. There seem to be lots of classes that
sound exactly like what I want however they either don''t convert to unicode
or they expect the data to be in a byte array. Trying to convert the dataset
values from object to a byte array causes a invalid cast exception.

Any ideas or links to detail info about the encoding stuff would be much
appreciated.

Regards,
Peter

解决方案

Peter Row <pe*******@oxfordcc.co.uk> wrote:

Here is my problem:

I have a SQL Server 2000 DB with various NVarChar, NText fields in its
tables.
For some stupid reason the data was inserted into these fields in UTF8
encoding.
That shouldn''t make any odds - the encoding shouldn''t matter at all, as
what will end up in the database is unicode characters.
However when you retrieve these values into a dataset and ToString() them
some characters come out as garbage.

So therefore I have started writing a throw away app that will go through
all the
relevant tables and fields decoding and then updating with unicode values.

However I''m a bit confused and stuck. There seem to be lots of classes that
sound exactly like what I want however they either don''t convert to unicode
or they expect the data to be in a byte array. Trying to convert the dataset
values from object to a byte array causes a invalid cast exception.

Any ideas or links to detail info about the encoding stuff would be much
appreciated.



See http://www.pobox.com/~skeet/csharp/unicode.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Peter Row <pe*******@oxfordcc.co.uk> wrote:

Here is my problem:

I have a SQL Server 2000 DB with various NVarChar, NText fields in its
tables.
For some stupid reason the data was inserted into these fields in UTF8
encoding.
That shouldn''t make any odds - the encoding shouldn''t matter at all, as
what will end up in the database is unicode characters.
However when you retrieve these values into a dataset and ToString() them
some characters come out as garbage.

So therefore I have started writing a throw away app that will go through
all the
relevant tables and fields decoding and then updating with unicode values.

However I''m a bit confused and stuck. There seem to be lots of classes that
sound exactly like what I want however they either don''t convert to unicode
or they expect the data to be in a byte array. Trying to convert the dataset
values from object to a byte array causes a invalid cast exception.

Any ideas or links to detail info about the encoding stuff would be much
appreciated.



See http://www.pobox.com/~skeet/csharp/unicode.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Hi Jon,

I told Peter in the language.vb group to ask this in here, because there was
the expert Jon Skeet, I think you can better.

(Now my advise looks as nothing and maybe I do it myself although I am not
that expert of course)
Cor


这篇关于从数据集解码文本,嗯...帮助赞赏。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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