|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
storing unicode in byte array?I'm trying to save unicode chars. in byte array. The problem is when I try retrieve the saved chars back from the array I get different chars from the one I saved. Code: dim uni as system.text.encoding=encoding.unicode dim byte1 as byte()=uni.getbytes(1607) '1607 is the unicode represnt. of an arabic letter 'now retrieve saved char. (number) from byte1() messagebox.show(byte1(0) & byte1(1)) ' it shows different value..?? Now, may be I did not get byte array clear. But it is a series of bytes to save number 0-255, so what I did here is I just saved the unicode numbers contiguously. MTIA, Grawsha Hello grawsha2***@yahoo.com,
First off, Turn Option Strict On. Second, read the documentation. Guessing only makes you look stoopid. The Encoding.GetBytes() function does not take a single numerical value. -Boo Show quoteHide quote > Hi, > > I'm trying to save unicode chars. in byte array. The problem is when > I try retrieve the saved chars back from the array I get different > chars from the one I saved. > > Code: > > dim uni as system.text.encoding=encoding.unicode > dim byte1 as byte()=uni.getbytes(1607) '1607 is the unicode > represnt. of an arabic letter > 'now retrieve saved char. (number) from byte1() > > messagebox.show(byte1(0) & byte1(1)) ' it shows different > value..?? > > Now, may be I did not get byte array clear. But it is a series of > bytes to save number 0-255, so what I did here is I just saved the > unicode numbers contiguously. > > MTIA, > Grawsha Ok, may be you did not understand my post well.
If I pass an arabic letter to the method, it will appear as junk in non-arbic supported browser. That is why I indicated the number for the letter. GhostInAK wrote: Show quoteHide quote > Hello grawsha2***@yahoo.com, > > First off, Turn Option Strict On. Second, read the documentation. Guessing > only makes you look stoopid. > > The Encoding.GetBytes() function does not take a single numerical value. > > -Boo > > > Hi, > > > > I'm trying to save unicode chars. in byte array. The problem is when > > I try retrieve the saved chars back from the array I get different > > chars from the one I saved. > > > > Code: > > > > dim uni as system.text.encoding=encoding.unicode > > dim byte1 as byte()=uni.getbytes(1607) '1607 is the unicode > > represnt. of an arabic letter > > 'now retrieve saved char. (number) from byte1() > > > > messagebox.show(byte1(0) & byte1(1)) ' it shows different > > value..?? > > > > Now, may be I did not get byte array clear. But it is a series of > > bytes to save number 0-255, so what I did here is I just saved the > > unicode numbers contiguously. > > > > MTIA, > > Grawsha Hi grawsha,
Well, you need to call Encoding.Unicode.GetChars to convert bytes back to chars. Cheers, Ahmed grawsha2***@yahoo.com wrote: Show quoteHide quote > Ok, may be you did not understand my post well. > > If I pass an arabic letter to the method, it will appear as junk in > non-arbic supported browser. That is why I indicated the number for > the letter. > > > GhostInAK wrote: > > Hello grawsha2***@yahoo.com, > > > > First off, Turn Option Strict On. Second, read the documentation. Guessing > > only makes you look stoopid. > > > > The Encoding.GetBytes() function does not take a single numerical value. > > > > -Boo > > > > > Hi, > > > > > > I'm trying to save unicode chars. in byte array. The problem is when > > > I try retrieve the saved chars back from the array I get different > > > chars from the one I saved. > > > > > > Code: > > > > > > dim uni as system.text.encoding=encoding.unicode > > > dim byte1 as byte()=uni.getbytes(1607) '1607 is the unicode > > > represnt. of an arabic letter > > > 'now retrieve saved char. (number) from byte1() > > > > > > messagebox.show(byte1(0) & byte1(1)) ' it shows different > > > value..?? > > > > > > Now, may be I did not get byte array clear. But it is a series of > > > bytes to save number 0-255, so what I did here is I just saved the > > > unicode numbers contiguously. > > > > > > MTIA, > > > Grawsha GhostInAK wrote:
> Hello grawsha2***@yahoo.com, LOL!! Reading some posts made me sure that there are alot stupid> > First off, Turn Option Strict On. Second, read the documentation. Guessing > only makes you look stoopid. > > The Encoding.GetBytes() function does not take a single numerical value. > > -Boo > people!! Grawsha <grawsha2***@yahoo.com> schrieb:
> I'm trying to save unicode chars. in byte array. The problem is when I Try to pass 'ChrW(1607)' to 'GetBytes'. Note that 'Encoding.Unicode' means > try retrieve the saved chars back from the array I get different chars > from the one I saved. > > Code: > > dim uni as system.text.encoding=encoding.unicode > dim byte1 as byte()=uni.getbytes(1607) '1607 is the unicode > represnt. of an arabic letter UTF-16. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Object reference not set to an instance of an object error
User Control c# to vb.net conversion Using VS 2005 my challenges with merging 2 Regex.Matches Authenticating to a service problem 1 - debugging guids Schema Information not found in web.config Printdocument.PrintPage cancel current printpage ASP.NET profile database |
|||||||||||||||||||||||