PC Review


Reply
Thread Tools Rate Thread

Non-Unicode strings in VB.NET?

 
 
Alain Dekker
Guest
Posts: n/a
 
      11th Feb 2010
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


 
Reply With Quote
 
 
 
 
Mihai N.
Guest
Posts: n/a
 
      12th Feb 2010
> 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"


--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      12th Feb 2010
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 ?

--
Patrice


"Alain Dekker" <(E-Mail Removed)> a écrit dans le message de
groupe de discussion : #(E-Mail Removed)...
> 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
>
>


 
Reply With Quote
 
Alain Dekker
Guest
Posts: n/a
 
      12th Feb 2010
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

"Patrice" <http://scribe-en.blogspot.com/> wrote in message
news:(E-Mail Removed)...
> 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 ?
>
> --
> Patrice
>
>
> "Alain Dekker" <(E-Mail Removed)> a écrit dans le message de
> groupe de discussion : #(E-Mail Removed)...
>> 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
>>
>>

>



 
Reply With Quote
 
Markus Betz
Guest
Posts: n/a
 
      12th Feb 2010
On 10-02-12 16:25, Alain Dekker wrote:
> 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
 
Reply With Quote
 
Markus Betz
Guest
Posts: n/a
 
      12th Feb 2010
On 10-02-12 16:25, Alain Dekker wrote:
> 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
 
Reply With Quote
 
Alain Dekker
Guest
Posts: n/a
 
      14th Feb 2010
Thanks Markus!

"Markus Betz" <(E-Mail Removed)> wrote in message
news:4b75cc73$0$6576$(E-Mail Removed)...
> On 10-02-12 16:25, Alain Dekker wrote:
>> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strings Strings Strings from sql ds. =?Utf-8?B?Q2hyaXN0b3BoZXI=?= Microsoft C# .NET 5 10th Dec 2004 01:20 AM
Make Word displays strings of text, not strings of code =?Utf-8?B?WGVybw==?= Microsoft Word Document Management 2 9th Dec 2004 11:35 AM
Finding strings within strings =?Utf-8?B?Um9k?= Microsoft Excel Programming 1 2nd Dec 2003 06:34 PM
Finding strings within strings Rod Microsoft Excel Programming 1 2nd Dec 2003 06:19 PM
PN: Converting C Strings to managed strings Peter Nolan Microsoft VC .NET 0 21st Nov 2003 12:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:55 PM.