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. convert unicode to iransystem

convert unicode to iransystem

Scheduled Pinned Locked Moved C#
help
4 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.
  • M Offline
    M Offline
    mersad00
    wrote on last edited by
    #1

    Hi there, i'm really in need of a convertor to convert unicode character map to iran system charachter map Please Help!

    B P K 3 Replies Last reply
    0
    • M mersad00

      Hi there, i'm really in need of a convertor to convert unicode character map to iran system charachter map Please Help!

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      I don't know what the Iranian character set is but assuming it is a 256 character set a bit like the western one you can have a static map which specifies what Unicode code point each Iranian byte index represents. Then you can look up Unicode code points in that map, converting anything that isn't found to a ?.

      1 Reply Last reply
      0
      • M mersad00

        Hi there, i'm really in need of a convertor to convert unicode character map to iran system charachter map Please Help!

        P Offline
        P Offline
        Pascal Ganaye
        wrote on last edited by
        #3

        I just had a look and this is a really interesting question. There are a few encoding in .NET that might be derived from the 'Iran System encoding standard' But they don't appear to be as described in the Wikipedia page[^].

        708: Arabic (ASMO 708) - different
        720: Arabic (DOS) - different
        864: Arabic (864) - different
        1256: Arabic (Windows) - different
        10004: Arabic (Mac) - not found
        20420: IBM EBCDIC (Arabic) - not found
        28596: Arabic (ISO) - different

        I thought it would be fun to try to write it then:

        class IranianSystemEncoding
        {
        static char[] ByteToChar;
        static Byte[][] CharToByte;

        static IranianSystemEncoding()
        {
            InitializeData();
        }
        
        static void InitializeData()
        {
            var iranSystem = new int\[\] { 0x06F0, 0x06F1, 0x06F2, 0x06F3, 0x06F4, 0x06F5, 0x06F6, 0x06F7, 0x06F8, 0x06F9, 0x060C, 0x0640, 0x061F, 0xFE81, 0xFE8B, 0x0621, 0xFE8D, 0xFE8E, 0xFE8F, 0xFE91, 0xFB56, 0xFB58, 0xFE95, 0xFE97, 0xFE99, 0xFE9B, 0xFE9D, 0xFE9F, 0xFB7C, 0xFB7C, 0xFEA1, 0xFEA3, 0xFEA5, 0xFEA7, 0x062F, 0x0630, 0x0631, 0x0632, 0x0698, 0xFEB1, 0xFEB3, 0xFEB5, 0xFEB7, 0xFEB9, 0xFEBB, 0xFEBD, 0xFEBF, 0x0637, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, 0x0638, 0xFEC9, 0xFECA, 0xFECC, 0xFECB, 0xFECD, 0xFECE, 0xFED0, 0xFECF, 0xFED1, 0xFED3, 0xFED5, 0xFED7, 0xFB8E, 0xFB90, 0xFB92, 0xFB94, 0xFEDD, 0xFEFB, 0xFEDF, 0xFEE1, 0xFEE3, 0xFEE5, 0xFEE7, 0x0648, 0xFEE9, 0xFEEC, 0xFEEB, 0xFBFD, 0xFBFC, 0xFBFE, 0x00A0 };
            ByteToChar = new char\[256\];
            // ascii first
            for (int i = 0; i < 128; i++) ByteToChar\[i\] = (char)i;
            // non-ascii
            for (int i = 128; i < 256; i++) ByteToChar\[i\] = (char)iranSystem\[i - 128\];
        
            // ok now reverse
            CharToByte = new Byte\[256\]\[\];
            for (int i = 0; i < 256; i++)
            {
                char ch = (char)ByteToChar\[i\];
                var low = ch & 0xff;
                var high = ch >> 8 & 0xff;
        
                var lowCharToByte = CharToByte\[high\];
        
        1 Reply Last reply
        0
        • M mersad00

          Hi there, i'm really in need of a convertor to convert unicode character map to iran system charachter map Please Help!

          K Offline
          K Offline
          Keith Barrow
          wrote on last edited by
          #4

          I don't think there is a direct way to do this, from the brief research I did it looks like the Iran System is obsolete, though that doesn't help your problem. My advices is to create a Map which maps the numeric value of the Iranian System to the numeric equivalent in Unicode and vice versa. This isn't a huge problem but:

          1. There isn't a map type in .net, which is a pity. You can fudge it a few ways, I've done it via dictionary (it is close with key/value instead of "key"/"key"), there is a discussion here[^]
          2. Entering the numberic values by hand in code or config or somesuchis error prone. This[^] should help as there is a [almost] copy and paste value mapping

          Internationized text is a real pain (as I'm learning to my cost), it is even worse for right-to-left languages such as Farsi.

          Sort of a cross between Lawrence of Arabia and Dilbert.[^]
          -Or-
          A Dead ringer for Kate Winslett[^]

          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