converting short to unicode without System.Text.UnicodeEncoding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • iwdu15

    #1

    converting short to unicode without System.Text.UnicodeEncoding

    hi, how can i convert type Short to Unicode strings? the
    System.Text.Uni codeEncoding cant convert it if the length is too shrot....so
    i need to do this manually. how can i do this
    --
    -iwdu15
  • Steven Nagy

    #2
    Re: converting short to unicode without System.Text.Uni codeEncoding

    Aren't strings in dotnet in unicode by default?

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

    Or am I completely missing the point here?

    Comment

    • Larry Lard

      #3
      Re: converting short to unicode without System.Text.Uni codeEncoding


      iwdu15 wrote:
      hi, how can i convert type Short to Unicode strings? the
      System.Text.Uni codeEncoding 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.ToStrin g


      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

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: converting short to unicode without System.Text.Uni codeEncoding

        "iwdu15" <jmmgoalsteraty ahoodotcomschri eb:
        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/>

        Comment

        • iwdu15

          #5
          Re: converting short to unicode without System.Text.Uni codeEncodin

          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

          Comment

          • Steven Nagy

            #6
            Re: converting short to unicode without System.Text.Uni codeEncodin

            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:
            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

            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: converting short to unicode without System.Text.Uni codeEncodin

              "Steven Nagy" <learndotnet@ho tmail.comschrie b:
              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/>

              Comment

              Working...