Compress a string

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

    #1

    Compress a string

    I have a long string, actually a MAPI entry ID that I want to compress down
    for storing into a database. An example is:
    "0000000020CCCF AC05C0B14B920BE 916F0ADEC540700 12EA1E9997A09B4 391EA8D617B81A9 5
    3000000004E4600 0012EA1E9997A09 B4391EA8D617B81 A953000000005D8 20000"

    Anybody have any ides On how this could be performed. It's not mission
    critical so we would prefer not to buy 3rd party tools.

    Cheers,


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Compress a string

    Darren,

    The best way I could think of to do this would be to actually represent
    the number in a byte array. Since the number is a hexidecimal value, the
    first four zeros could be stored as one byte. Do this to the whole string,
    and you would need only 35 bytes instead of the 140 you would need to store
    the string itself.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - casperOne@caspe rshouse.com

    "Darren B" <darren.b@fwbs. net> wrote in message
    news:%23uSa98YZ DHA.2024@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    > I have a long string, actually a MAPI entry ID that I want to compress[/color]
    down[color=blue]
    > for storing into a database. An example is:
    >[/color]
    "0000000020CCCF AC05C0B14B920BE 916F0ADEC540700 12EA1E9997A09B4 391EA8D617B81A9 5[color=blue]
    > 3000000004E4600 0012EA1E9997A09 B4391EA8D617B81 A953000000005D8 20000"
    >
    > Anybody have any ides On how this could be performed. It's not mission
    > critical so we would prefer not to buy 3rd party tools.
    >
    > Cheers,
    >
    >[/color]


    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: Compress a string

      Darren,

      I made a little mistake, every two characters is one byte, not every
      four characters. This would still cut the length in half.


      --
      - Nicholas Paldino [.NET/C# MVP]
      - nicholas.paldin o@exisconsultin g.com

      "Darren B" <darren.b@fwbs. net> wrote in message
      news:%23uSa98YZ DHA.2024@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > I have a long string, actually a MAPI entry ID that I want to compress[/color]
      down[color=blue]
      > for storing into a database. An example is:
      >[/color]
      "0000000020CCCF AC05C0B14B920BE 916F0ADEC540700 12EA1E9997A09B4 391EA8D617B81A9 5[color=blue]
      > 3000000004E4600 0012EA1E9997A09 B4391EA8D617B81 A953000000005D8 20000"
      >
      > Anybody have any ides On how this could be performed. It's not mission
      > critical so we would prefer not to buy 3rd party tools.
      >
      > Cheers,
      >
      >[/color]


      Comment

      Working...