473,698 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

storing unicode in byte array?

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.enc oding=encoding. unicode
dim byte1 as byte()=uni.getb ytes(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

Jun 21 '06 #1
5 2138
Hello gr*********@yah oo.com,

First off, Turn Option Strict On. Second, read the documentation. Guessing
only makes you look stoopid.

The Encoding.GetByt es() 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.enc oding=encoding. unicode
dim byte1 as byte()=uni.getb ytes(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

Jun 21 '06 #2
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 gr*********@yah oo.com,

First off, Turn Option Strict On. Second, read the documentation. Guessing
only makes you look stoopid.

The Encoding.GetByt es() 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.enc oding=encoding. unicode
dim byte1 as byte()=uni.getb ytes(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


Jun 21 '06 #3
Hi grawsha,

Well, you need to call Encoding.Unicod e.GetChars to convert bytes back
to chars.

Cheers,
Ahmed

gr*********@yah oo.com wrote:
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 gr*********@yah oo.com,

First off, Turn Option Strict On. Second, read the documentation. Guessing
only makes you look stoopid.

The Encoding.GetByt es() 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.enc oding=encoding. unicode
dim byte1 as byte()=uni.getb ytes(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


Jun 21 '06 #4
<gr*********@ya hoo.com> schrieb:
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.enc oding=encoding. unicode
dim byte1 as byte()=uni.getb ytes(1607) '1607 is the unicode
represnt. of an arabic letter


Try to pass 'ChrW(1607)' to 'GetBytes'. Note that 'Encoding.Unico de' means
UTF-16.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 21 '06 #5

GhostInAK wrote:
Hello gr*********@yah oo.com,

First off, Turn Option Strict On. Second, read the documentation. Guessing
only makes you look stoopid.

The Encoding.GetByt es() function does not take a single numerical value.

-Boo

LOL!! Reading some posts made me sure that there are alot stupid
people!!

Grawsha

Jul 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
2754
by: aurora | last post by:
I have long find the Python default encoding of strict ASCII frustrating. For one thing I prefer to get garbage character than an exception. But the biggest issue is Unicode exception often pop up in unexpected places and only when a non-ASCII or unicode character first found its way into the system. Below is an example. The program may runs fine at the beginning. But as soon as an unicode character u'b' is introduced, the program boom...
2
36562
by: Dunc | last post by:
Hi, I've got an HttpWebResponse object, all working fine. I'm getting the underlying stream and currently writing it to a file using the ReadToEnd() method. All happy. I want to do a bit of manipulation before writing this to the disk; can anyone point me in the right direction of how to copy it to a byte array so I can make my mods before writing it to the disk?
2
3541
by: Gidi | last post by:
Hi, I'm writing a C# win application program, and i need to transfer my hebrew letters from unicode to ascii, now if i use the ascii encoding it writes me ??? instead of the hebrew letter i've entered. I know what the Ascii value of each letter, so i understood that i can transfer my string to BYTE and enter the ascii value by myself. if someone has a better idea, i'll be happy to hear about it. how can i know the Unicode value of a...
1
17532
by: anantvrana | last post by:
Hello All, I am trying to read Unicode (Kanji character) data from a text file. When I store unicode data into variable my Kanji character gets messed up. I am using following code Open File1 For Input Access Read As #1 While Not EOF(1)
18
34133
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found Encoding.Convert, but that needs byte arrays. Thanks, /Ger
1
1772
by: Scott Duckworth | last post by:
Can anyone provide a quick code snippit to open a text file and tell if it's ASCII or Unicode? Thanks
1
3081
by: tony.pahl | last post by:
We are converting a data warehouse to a Unicode database to get ready for multilingual support. If we will have 95% of our data in English as we currently do, and less than 5% in other foreign languages including Japanese, it appears as if we would be best off using codepage of 1208 and UTF-8. We are thinking we would need to expand our 'char' and 'varchar' datatypes by four times to accommadate the Japanese data. Using 'varchar' should...
13
2962
by: gabor | last post by:
hi, from the documentation (http://docs.python.org/lib/os-file-dir.html) for os.listdir: "On Windows NT/2k/XP and Unix, if path is a Unicode object, the result will be a list of Unicode objects." i'm on Unix. (linux, ubuntu edgy)
6
18049
by: msdnuniv | last post by:
Hello everybody, since days i try to convert Unicode-Strings in VB.NET to ANSI which should be processable in VB6 and converted to unicode again. It should be possible with any codepage, e.g. somebody on a greek PC should be able to handle chinese strings -------------- VB.NET ---------------- 'On the vb.net side (I am pretty sure, it is correct(?)) Dim oEncoderAnsi As System.Text.Encoding
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.