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

  • SEARCH
  • Home
  • 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 9170293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:59:49+00:00 2026-06-17T15:59:49+00:00

I have written a dead-simple serialization format which encodes unsigned integers by first converting

  • 0

I have written a dead-simple serialization format which encodes unsigned integers by first converting them into bytes in big-endian form and then prefixing them with a single byte specifying the number of bytes which the number takes up. Eg. 3 = 01 03, 268 = 02 01 0C. The range of integers is therefore 0 to 2^255 - 1.

I use this to serialize strings by prefixing the string with the encoding of its length, and I can then serialize arbitrary structures quite easily, for example a list of strings is an encoding of the number of elements followed by the encoding of each of the strings.

Here it is in PHP: https://gist.github.com/4577886.

My question is: What do you call this method of serialization? Is it very often used? Is there anything wrong with it?

Thanks.

  • 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-06-17T15:59:50+00:00Added an answer on June 17, 2026 at 3:59 pm

    It’s kind of type-length-value, without the type. And that’s what’s wrong with it. How do you know whether the next 4 bytes are an int or a string or a 4-byte array?

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

Sidebar

Related Questions

I have written a raw binary image file into a buffer which is an
I have written a simple .NET webservice, which I will be hosted on a
have written this little class, which generates a UUID every time an object of
I have written a bash script which installs a number of packages, however for
I have written a very simple CTE expression that retrieves a list of all
have written a stochastic simulation in Java, which loads data from a few CSV
I have a simple application on a OpenWRT style router. It's written in C++
I have video files written in avi format and I would like to analyze
Have just written a small app to read from our MSMQ dead letter queue,
I have written a snippet in which an image is saved using ajax and

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.