Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2006

Tip: Looking for answers? Try searching our database.

Differences in UnicodeEncoding library between .Net 2.0 and 1.1

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim - 12 Jun 2006 19:05 GMT
Hello All,

I have an issue with the unicodeencoding library. The following code:

           m_key= New Byte(127) {&HCD, &H1, &H0, &H0, &H8, &H9, &HCB,
&H0, _

 &HFE, &HAA, &H9, &H10, &H7, &HA, &HA1, &H2E, _

 &H8F, &HBB, &H6, &H2, &H6, &HB, &HB2, &H0, _

 &H44, &HCC, &HAA, &H3C, &H5, &HC, &HC3, &H4B, _

 &H39, &H5E, &HA6, &H5E, &H4, &HD, &HD4, &HB4, _

 &H9F, &H57, &H6F, &HE8, &H3, &HE, &HE5, &H3A, _

 &H78, &H12, &H4B, &HE6, &H2, &HF, &HF6, &H2E, _

 &H56, &H34, &H0, &H4E, &H1, &H11, &H4, &H41, _

 &HDC, &H11, &H10, &H20, &H38, &H67, &HC3, &H60, _

 &HFE, &HAA, &H9, &H10, &H7, &HA, &HA1, &H2E, _

 &HF3, &HBB, &H6, &H12, &H26, &HE, Rest of key ommitted for security
reasons but the array contains 128 elements}

           Dim cEncoding As New UnicodeEncoding()
           m_sKey = cEncoding.GetString(m_key)

returns a m_sKey variable with a length of 64 in .Net 1.1 (which is
correct) but when run under 2.0, it returns a m_sKey variable whose
length is only 62.

Any clues? Any help would be greatly appreciated.
Barry Kelly - 12 Jun 2006 23:34 GMT
> I have an issue with the unicodeencoding library. The following code:
>
>             m_key= New Byte(127) {&HCD, &H1, &H0, &H0, &H8, &H9, &HCB,
> &H0, _

[snip]

>   &HF3, &HBB, &H6, &H12, &H26, &HE, Rest of key ommitted for security
> reasons but the array contains 128 elements}
[quoted text clipped - 5 lines]
> correct) but when run under 2.0, it returns a m_sKey variable whose
> length is only 62.

The data you have given (the array above) produces the same string in
both .NET 1.1 and .NET 2.0. It would be easier to help if you could
provide data that reproduces the effect.

> Any clues? Any help would be greatly appreciated.

What are you storing in the string? It seems like you are not actually
storing text at all (you've got a null character in there) - in which
case, you can't depend on exact binary translations from one version to
another of the .NET Encoding classes, as undefined code points may
become defined, and the Unicode standard changes, bugs get fixed, etc.

To store byte data like keys, use byte arrays. If you need a string
representation, use something like Convert.ToBase64() and
Convert.FromBase64() to round-trip the byte arrays.

-- Barry

Signature

http://barrkel.blogspot.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.