VS2005打破了我的VS2003代码 [英] VS2005 broke my VS2003 Code

查看:48
本文介绍了VS2005打破了我的VS2003代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚启动了VS 2005的生产版本。我的第一个活动是

转换我在VS2003 .Net 1.1中编写的应用程序.....新版本

和旧版本的工作方式不一样...我发现了一小段代码,

会产生不同的[和.net 1.1观点不正确]结果。

问题代码是:


byte [] cipherText =字节数组,lenght = 48 - > 24个unicode字符

byte [] plaintext = null;

byte [] plaintextBlock = null;

byte [] cipherBlock = null;

int indexToRead = 0;

int readLength = 0;

String cipherTextString ="" ;;

String plainTextString ="" ;;

cipherTextString = Encoding.Unicode.GetString(cipherText); < - 这不是

和以前一样工作


而不是 - >长度为24的cipherTextString我得到23的长度。{I

在vs2003中运行相同的代码,我得到正确的24个字符长度}


非常感谢任何帮助。

I just fired up the production version of VS 2005. My first activity was to
convert an application that I wrote in VS2003 .Net 1.1..... The new version
does not work the same as the old...Ive found a single bit of code that
produces a different [and from a .net 1.1 point of view incorrect] result.
The problem code is:

byte[] cipherText = byte array with lenght=48 --> 24 unicode characters
byte[] plaintext = null;
byte[] plaintextBlock = null;
byte[] cipherBlock = null;
int indexToRead =0;
int readLength = 0;
String cipherTextString ="";
String plainTextString = "";
cipherTextString = Encoding.Unicode.GetString(cipherText); <-- this is not
working the same as before

Instead of --> cipherTextString with length of 24 I get a length of 23. {I
run the same code in the vs2003 and I get the correct 24 character length}

Any help is greatly appreciated.

推荐答案


byte [] cipherText = byte数组与lenght = 48 - > 24个unicode字符
byte[] cipherText = byte array with lenght=48 --> 24 unicode characters




给我们真实的字符串,它是cipherText。

注意,cipherText的长度必须*不是* 48 ! for

每[24]个unicode字符组合。

一个unicode字符可以例如也包含3个字节。
http:// www。 yoda.arachsys.com/csharp/unicode.html

ciao Frank

-

Dipl.Inf。 Frank Dzaebel [MCP / MVP C#]
http://Dzaebel.NET


Frank Dzaebel< Po ** @ FranksSeite.de>写道:
Frank Dzaebel <Po**@FranksSeite.de> wrote:
byte [] cipherText =字节数组,lenght = 48 - > 24个unicode字符
byte[] cipherText = byte array with lenght=48 --> 24 unicode characters



给我们真正的字符串,这是cipherText。
注意,cipherText的长度必须*不是* 48!
每[24]个unicode字符组合。
一个unicode字符可以例如也包含3个字节。
http:// www。 yoda.arachsys.com/csharp/unicode.html




不是Unicode编码,即UTF-16。 48字节应该

总是给出24个UTF-16代码点,我相信。


-

Jon Skeet - < sk***@pobox.com>
http://www.pobox。 com / ~siget 博客: http://www.msmvps.com/ jon.skeet

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



Not in terms of the Unicode encoding, which is UTF-16. 48 bytes should
always give 24 UTF-16 code points, I believe.

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


katzky< ka **** @ discussions.microsoft.com>写道:
katzky <ka****@discussions.microsoft.com> wrote:
我刚刚启动了VS 2005的生产版本。我的第一个活动是转换我在VS2003 .Net 1.1中编写的应用程序.....新版本
与旧版本的工作方式不同...我发现了一些代码,它们会产生不同的[和.net 1.1的观点不正确]结果。
问题代码是:

byte [] cipherText =字节数组,lenght = 48 - > 24个unicode字符
byte [] plaintext = null;
byte [] plaintextBlock = null;
byte [] cipherBlock = null;
int indexToRead = 0;
int readLength = 0;
String cipherTextString ="" ;;
String plainTextString ="" ;;

cipherTextString = Encoding.Unicode.GetString(cipherText); < - 这不是和以前一样工作

而不是 - > cipherTextString长度为24我的长度为23. {我在vs2003中运行相同的代码,我得到正确的24个字符长度}

非常感谢任何帮助。
I just fired up the production version of VS 2005. My first activity was to
convert an application that I wrote in VS2003 .Net 1.1..... The new version
does not work the same as the old...Ive found a single bit of code that
produces a different [and from a .net 1.1 point of view incorrect] result.
The problem code is:

byte[] cipherText = byte array with lenght=48 --> 24 unicode characters
byte[] plaintext = null;
byte[] plaintextBlock = null;
byte[] cipherBlock = null;
int indexToRead =0;
int readLength = 0;
String cipherTextString ="";
String plainTextString = "";
cipherTextString = Encoding.Unicode.GetString(cipherText); <-- this is not
working the same as before

Instead of --> cipherTextString with length of 24 I get a length of 23. {I
run the same code in the vs2003 and I get the correct 24 character length}

Any help is greatly appreciated.




这里有一个基本问题,假设每个有效字节

数组都是有效的UTF-16码点序列。它始终是一系列的UTF-16代码点,但其中一些代码点可能无效,

根本没有被定义,或者是一个代理对的一半。


要在文本中表示二进制数据,您应该使用类似base16

(十六进制)或base64编码的东西。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet

如果回复该群组,请不要给我发邮件太



You''ve got a fundamental problem here, assuming that every valid byte
array is a valid UTF-16 codepoint sequence. It''s always a sequence of
UTF-16 code points, but some of those code points may be invalid,
either not being defined at all, or being one half of a surrogate pair.

To represent binary data in text, you should use something like base16
(hex) or a base64 encoding.

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


这篇关于VS2005打破了我的VS2003代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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