Non-Unicode strings in VB.NET?

A

Alain Dekker

I've been reading the MSDN documentation on the System.Char and
System.String types and they mention Unicode throughout without even
mentioning non-Unicode versions. How do I get a gool 'ol one-byte char and
non-Unicode string in .NET?

Thanks,
Alain
 
M

Mihai N.

I've been reading the MSDN documentation on the System.Char and
System.String types and they mention Unicode throughout without even
mentioning non-Unicode versions. How do I get a gool 'ol one-byte char and
non-Unicode string in .NET?

You don't.
You can get a byte array, but there is no such thing as "non-Unicode string"
 
P

Patrice

Hello,

Some more context would help.

..NET uses only unicode strings. You could use a byte array. If this is for
interop the conversion can be handled for you (or you could use the
appropriate methods yourself). System.Text.Encoding could also help etc...

What are you trying to do that requires non unicode strings ?
 
A

Alain Dekker

I'm communicating with a legacy app that does not support UNICODE. In fact,
UNICODE is superfluous for this project. Wish there was a way to turn it
off, but I know and appreciate why its been done.

After your post I found the System.Encoding.ASCII feature and it does what I
expect. I presume is is transparently handling the second BYTE of each
two-BYTE character, but for display purposes its fine.

Many thanks,
Alain
 
M

Markus Betz

I'm communicating with a legacy app that does not support UNICODE. In fact,
UNICODE is superfluous for this project. Wish there was a way to turn it
off, but I know and appreciate why its been done.

After your post I found the System.Encoding.ASCII feature and it does what I
expect. I presume is is transparently handling the second BYTE of each
two-BYTE character, but for display purposes its fine.

Hello Alain,

ASCII is restricted to 7 bits. To get the whole lower byte (i.e. the
first 256 chars of Unicode) you should use:

System.Text.Encoding.GetEncoding("ISO-8859-1")

or any other code-set you legacy application likes.

Markus
 
M

Markus Betz

I'm communicating with a legacy app that does not support UNICODE. In fact,
UNICODE is superfluous for this project. Wish there was a way to turn it
off, but I know and appreciate why its been done.

After your post I found the System.Encoding.ASCII feature and it does what I
expect. I presume is is transparently handling the second BYTE of each
two-BYTE character, but for display purposes its fine.

Hello Alain,

ASCII is restricted to 7 bits. To get the whole lower byte (i.e. the
first 256 chars of Unicode) you should use:

System.Text.Encoding.GetEncoding("ISO-8859-1")

or any other code-set your legacy application likes.

Markus
 
A

Alain Dekker

Thanks Markus!

Markus Betz said:
Hello Alain,

ASCII is restricted to 7 bits. To get the whole lower byte (i.e. the first
256 chars of Unicode) you should use:

System.Text.Encoding.GetEncoding("ISO-8859-1")

or any other code-set your legacy application likes.

Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top