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. Converting string data(which contains EBCDIC, Packed decimal and Endian data) to byte array

Converting string data(which contains EBCDIC, Packed decimal and Endian data) to byte array

Scheduled Pinned Locked Moved C#
databasedata-structuresquestion
2 Posts 2 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.
  • D Offline
    D Offline
    deep7
    wrote on last edited by
    #1

    Hi, I need to convert string which has EBCDIC, packed decimal and Endian data to byteArray to save it in the database. I tried the following code. Byte[] updateByte; updateByte = System.Text.Encoding.Default.GetBytes(strData); //here, strData is the string Here what happens is it converts some characters to '?' with decimal value 63. For e.g. abc(ASCII vale) after converting to EBCDIC i get [129 130 131](these are decimal values of the converted EBCDIC data). When i convert the string to byte array in order to save it in database, it changes all three characters(129, 130 and 131) to 63. This mostly happens with small case alpbhbets. I also tried other encoding(EBCDIC-US) but this also changes more characters. IMP: Please note that the string that i need to convert to byte array contains EBCDIC, Packed decimal and Also Endian data. Kindly let me know how i can achieve this. Thanks, Deepa

    L 1 Reply Last reply
    0
    • D deep7

      Hi, I need to convert string which has EBCDIC, packed decimal and Endian data to byteArray to save it in the database. I tried the following code. Byte[] updateByte; updateByte = System.Text.Encoding.Default.GetBytes(strData); //here, strData is the string Here what happens is it converts some characters to '?' with decimal value 63. For e.g. abc(ASCII vale) after converting to EBCDIC i get [129 130 131](these are decimal values of the converted EBCDIC data). When i convert the string to byte array in order to save it in database, it changes all three characters(129, 130 and 131) to 63. This mostly happens with small case alpbhbets. I also tried other encoding(EBCDIC-US) but this also changes more characters. IMP: Please note that the string that i need to convert to byte array contains EBCDIC, Packed decimal and Also Endian data. Kindly let me know how i can achieve this. Thanks, Deepa

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, that doesn't make much sense. 1. in .NET a sttring consists of Unicode characters, nothing else. 2. in a database, data is stored in fields, having some type, such as NVARCHAR. 3. "packed decimal" needs details 4. AFAIK "Endian data" does not exist; multi-byte data (such as int or float) can be stored in big-endian or little-endian mode, where one is "natural" on a given system and the other isn't. I suggest you provide: 1. a better explanation of what it is you want 2. two examples with available input data, and the corresponding output data you hope to get (use either all decimal, or better yet all hexadecimal). :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


      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