473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PackedLen in the string binary representation

Hi there,

when stored in the binaries (or in metadata), strings are represented in
a special format: the length is followed by the string data.

However, I do not quite understand this PackedLen value that precedes
consecutive bytes. I've made some experiments and figured out that 8-bit
numbers are stored as they are (single byte) and numbers greater than 255
are stored on 2 bytes with trailing 8 (for example 1495 is 85D7).

Could anyone explain this PackedLen format to me? Is it some kind of
standard? Unfortunately, I have no idea what the google should be asked for.

Regards,
Wiktor Zychla
Nov 16 '05 #1
2 1918
Wiktor,
Could anyone explain this PackedLen format to me? Is it some kind of
standard? Unfortunately, I have no idea what the google should be asked for.


The length is a compressed integer, stored using the compression
algorithm used in many other places in metadata. It's described in
Partition II, 22.2. Basicly it goes like this

If value is 0-127, store it in the 7 least significant bits in a
single byte, and set the MSB to 0).
If value is 128-0x3fff, store it in the 14 least significant bits of a
16-bit word, and set the two high bits to binary 10. This is what
you're seeing - the 8 comes from the high nibble being 1000.
Otherwise (if value is 0x4000-0x1fffffff) store in a 32-bit word with
the three high bits set to binary 110.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
> Otherwise (if value is 0x4000-0x1fffffff) store in a 32-bit word with
the three high bits set to binary 110.


this is what I was looking for. thanks a lot, Mattias.

Regards,
Wiktor
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alexander Eisenhuth | last post by:
Hallo all there, maby I don't see the forest because of all that trees, but : from struct import * # how can I convert f = float(0.5)
3
by: Eric | last post by:
Guys, I have the following hexadecimal string - '\xff\xff\xff' which i need to convert to binary. How would i go about doing this? Eric
12
by: neutrino | last post by:
Greetings to the Python gurus, I have a binary file and wish to see the "raw" content of it. So I open it in binary mode, and read one byte at a time to a variable, which will be of the string...
4
by: Delali Dzirasa | last post by:
Does anyone know of the fastest way to convert a CString of numbers ie "00000001" to the binary representation in an int? for example CString myVal = "00000001"; int myIntVal = 0; ...
3
by: Tanuki | last post by:
Hi All: I encounter a programming problem recently. I need to read a binary file. I need to translate the binary data into useful information. I have the format at hand, like 1st byte = ID,...
8
by: Yeow | last post by:
hello, i was trying to use the fread function on SunOS and ran into some trouble. i made a simple test as follows: i'm trying to read in a binary file (generated from a fortran code) that...
10
by: 63q2o4i02 | last post by:
Hi, I'm using python to run some lab equipment using PyVisa. When I read a list of values from the equipment, one of the fields is 32 bits of flags, but the value is returned as a floating...
5
by: Andrea | last post by:
Hi, I'm a newbie i want to know how can i convert string to its binary representation, i want to write a program where an example string "hello world" is transformed in his binary representation...
26
by: Carramba | last post by:
Hi! How can I output value of char or int in binary form with printf(); ? thanx in advance
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.