Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Extended Ascii Encoding

Extended Ascii Encoding

Scheduled Pinned Locked Moved C#
questioncsharphelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zainu
    wrote on last edited by
    #1

    Hi I want to convert the unicode string ( in DotNet) to extended ascii bytes. I tried UTF8Encoding and ASCIIEncoding. But in UTF8Encoding i am two bytes for the £ ( character value 163) In ACSIIEncoding I am getting question mark (?). How can I convert the character £ to a ascii byte value Please Help Regards

    H 1 Reply Last reply
    0
    • Z zainu

      Hi I want to convert the unicode string ( in DotNet) to extended ascii bytes. I tried UTF8Encoding and ASCIIEncoding. But in UTF8Encoding i am two bytes for the £ ( character value 163) In ACSIIEncoding I am getting question mark (?). How can I convert the character £ to a ascii byte value Please Help Regards

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You have to specify a codepage. Any characters about 127 in ASCII (since ASCII defines 7-bit characters, not 8-bit) depend upon a codepage for what those characters represent

      byte[] ubuf = Encoding.Unicode.GetBytes(
      "This is a string stored as Unicode in .NET.");
      // Create an encoding for Windows-1252 codepage.
      Encoding enc = Encoding.GetEncoding(1252);
      byte[] abuff = Encoding.Convert(Encoding.Unicode, enc, ubuf);

      Microsoft MVP, Visual C# My Articles

      Z H 2 Replies Last reply
      0
      • H Heath Stewart

        You have to specify a codepage. Any characters about 127 in ASCII (since ASCII defines 7-bit characters, not 8-bit) depend upon a codepage for what those characters represent

        byte[] ubuf = Encoding.Unicode.GetBytes(
        "This is a string stored as Unicode in .NET.");
        // Create an encoding for Windows-1252 codepage.
        Encoding enc = Encoding.GetEncoding(1252);
        byte[] abuff = Encoding.Convert(Encoding.Unicode, enc, ubuf);

        Microsoft MVP, Visual C# My Articles

        Z Offline
        Z Offline
        zainu
        wrote on last edited by
        #3

        Hi Thanks for your time. In the above example will I get a extened ascii bytes at abuff ? Regards Shiraz

        H 1 Reply Last reply
        0
        • Z zainu

          Hi Thanks for your time. In the above example will I get a extened ascii bytes at abuff ? Regards Shiraz

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          Yes. As I said before, ASCII uses only 7-bit characters, so you only get characters below 128. You have to specify a codepage to get valid characters over that. Different regions use different codepages. The Greeks filled their last 128 characters with greek symbols, for example; the Russians with Cyrillic; so on, so forth. That link I provided will explain more.

          Microsoft MVP, Visual C# My Articles

          Y 1 Reply Last reply
          0
          • H Heath Stewart

            You have to specify a codepage. Any characters about 127 in ASCII (since ASCII defines 7-bit characters, not 8-bit) depend upon a codepage for what those characters represent

            byte[] ubuf = Encoding.Unicode.GetBytes(
            "This is a string stored as Unicode in .NET.");
            // Create an encoding for Windows-1252 codepage.
            Encoding enc = Encoding.GetEncoding(1252);
            byte[] abuff = Encoding.Convert(Encoding.Unicode, enc, ubuf);

            Microsoft MVP, Visual C# My Articles

            H Offline
            H Offline
            Hovik Melkomian
            wrote on last edited by
            #5

            Hi there: This code helped me much, but I exatcly need its opposite. How can I change the Unicode numbers to characters?! Tnx in Advance. Always:), Hovik Melkomian.

            H 1 Reply Last reply
            0
            • H Hovik Melkomian

              Hi there: This code helped me much, but I exatcly need its opposite. How can I change the Unicode numbers to characters?! Tnx in Advance. Always:), Hovik Melkomian.

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              char c = (int)65; c is now "A".

              Microsoft MVP, Visual C# My Articles

              1 Reply Last reply
              0
              • H Heath Stewart

                Yes. As I said before, ASCII uses only 7-bit characters, so you only get characters below 128. You have to specify a codepage to get valid characters over that. Different regions use different codepages. The Greeks filled their last 128 characters with greek symbols, for example; the Russians with Cyrillic; so on, so forth. That link I provided will explain more.

                Microsoft MVP, Visual C# My Articles

                Y Offline
                Y Offline
                yosr
                wrote on last edited by
                #7

                I want to write arabic letters, what codepage should i use to get arabic letters? thanks for your time :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups