Home All Groups Group Topic Archive Search About

converting short to unicode without System.Text.UnicodeEncoding

Author
13 Jul 2006 2:52 AM
iwdu15
hi, how can i convert type Short to Unicode strings? the
System.Text.UnicodeEncoding cant convert it if the length is too shrot....so
i need to do this manually. how can i do this
--
-iwdu15

Author
13 Jul 2006 3:38 AM
Steven Nagy
Aren't strings in dotnet in unicode by default?

Thus:
Dim s as short = 5
Dim u as string = CType(s, integer).ToString()

Or am I completely missing the point here?
Author
13 Jul 2006 9:53 AM
Larry Lard
iwdu15 wrote:
> hi, how can i convert type Short to Unicode strings? the
> System.Text.UnicodeEncoding cant convert it if the length is too shrot....so
> i need to do this manually. how can i do this

What do you mean? Values of type Short are numbers - do you just want
their decimal representations? All .NET Strings are Unicode, so you
just need to say

Dim myShort As Short = 5
Dim myString As String = myShort.ToString


Encodings are for translating between bytes and characters.

--
Larry Lard
Replies to group please
When starting a new topic, please mention which version of VB/C# you
are using
Author
13 Jul 2006 11:09 AM
Herfried K. Wagner [MVP]
"iwdu15" <jmmgoalsteratyahoodotcom> schrieb:
> hi, how can i convert type Short to Unicode strings?

I am not sure what you want to archieve, but maybe 'ChrW(x)' is what you are
looking for.  Note that Microsoft unfortunately uses the term Unicode
instead of UTF-16.  Strings are stored as UTF-16 in .NET.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
13 Jul 2006 11:59 AM
iwdu15
thanks, what im trying to o is read in header information from WMA and MP3
files. i did some reading on it and the websites i went to said that the .NET
functions for to Unicode characters needed a length of atleast 256 bytes....
--
-iwdu15
Author
13 Jul 2006 11:11 PM
Steven Nagy
256 bytes per unicode character? Wow, I don't think there are that many
alphabets in the Universe.

Is that statement even correct if you had of said 256 bits ? Thats 32
bytes I think. Thats, what, a double?

I'm just confusing myself.



iwdu15 wrote:
Show quoteHide quote
> thanks, what im trying to o is read in header information from WMA and MP3
> files. i did some reading on it and the websites i went to said that the .NET
> functions for to Unicode characters needed a length of atleast 256 bytes....
> --
> -iwdu15
Author
13 Jul 2006 11:25 PM
Herfried K. Wagner [MVP]
"Steven Nagy" <learndot***@hotmail.com> schrieb:
> 256 bytes per unicode character? Wow, I don't think there are that many
> alphabets in the Universe.
>
> Is that statement even correct if you had of said 256 bits ? Thats 32
> bytes I think. Thats, what, a double?

In UTF-32 each character is encoded using 32 bits (4 bytes).  UTF-16 uses 16
bits per character and 32 bits (surrogate pairs) for some Chinese
characters.

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