Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4549794
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:24:34+00:00 2026-05-21T16:24:34+00:00

I’ve got an quite simple class that contains some primitive types and some collections

  • 0

I’ve got an quite simple class that contains some primitive types and some collections with mostly enums. Now I need to serialize this object to the smallest possible size that is UTF8 compatible.

This is the class I need to serialize

public class Context
{
    public Hashtable UserModuleRoles { get; set; }
    public Dictionary<string, object> CustomSettings { get; set; }
    public int Uid { get; set; }
    public int Id { get; set; }
    public int ActiveId { get; set; }
    public byte Default { get; set; }
    public SetEnum Ident { get; set; }
    public string Name { get; set; }
    public sbyte State { get; set; }
    public DateTime Date { get; set; }
}

.

This is how I serialize the object

public string Serialize(object serializeObject)
{
    MemoryStream stream = new MemoryStream();
    BinaryFormatter b = new BinaryFormatter();

    b.Serialize(stream, serializeObject);

    byte[] data = stream.ToArray();

    stream.Dispose();
    stream = new MemoryStream();

    using (ZipFile zip = new ZipFile())
    {
        zip.AddEntry("data", data);
        zip.Save(stream);
    }

    data = stream.ToArray();
    stream.Dispose();

    return Convert.ToBase64String(data);
}

In my first attempt I serialize the object, zip that content (about 1/3 smaller) and convert it to a base64 string. But base64 has a quite big overhead of 1/3 and I know there is base128 but I don’t know how to start and my search for base128 encoding was unsuccessful.

  • Or is there any other way to do this?

  • And if not how is the best way to
    this as base128?

Edit:

I tested the ObjectStateFormatter Class with the whole “Context” object which results in 8byte more and slower serialization/deserialization. Maybe I had to use it just on the properties instead of the whole class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:24:34+00:00Added an answer on May 21, 2026 at 4:24 pm

    Well, base128 is not that hard, if you know how base64 is done. The dutch wikipedia describes the process well (translated it for you):

    1. Convert the data to binary.
    2. Keep taking chunks of 7 bits (2^7 = 128)
    3. Convert those 7 bits to an integer.
    4. Look up that integer in a translation table that you defined and append the character found to the base128 string.

    That translation table contains 128 compatible UTF8 characters, for example:

    0: a
    1: b
    ..
    25: z
    26: 0
    

    The only requirement is that translation table is the same at both sender and reciever.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.