|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Differences in UnicodeEncoding library between .Net 2.0 and 1.1I 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. "Jim" <jim.zafr***@gmail.com> wrote: [snip]> I have an issue with the unicodeencoding library. The following code: > > m_key= New Byte(127) {&HCD, &H1, &H0, &H0, &H8, &H9, &HCB, > &H0, _ > &HF3, &HBB, &H6, &H12, &H26, &HE, Rest of key ommitted for security The data you have given (the array above) produces the same string in> 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. 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 actuallystoring 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 |
|||||||||||||||||||||||