[mkgmap-dev] [PATCH] Bug in label encoding
From Ronny Klier ronny.klier at s1999.tu-chemnitz.de on Mon Feb 8 20:52:55 GMT 2010
Am 08.02.2010 10:46, schrieb Steve Ratcliffe: > On 07/02/10 23:47, Ronny Klier wrote: >> I think there is a bug in label encoding in Format6Encoder. For some >> string length the last encoded byte is not stored. >> >> E.g. having a string "10007" the encoded byte buffer looks like this >> >> [0] [0x86] >> [1] [0x8] >> [2] [0x20] >> [3] [0x9f] >> [4] [0xf0] >> >> The number of stored bytes is 4. So the 0xf0 will not show up in the >> final image file. > > I believe the code is correct and the 0xf0 is not required and omitted > on purpose. > > A 5 byte string where each character is encoded as 6 bits requires 30 > bits of storage which is 3.75 bytes. There is then a end-of-string > marker which is written as the 6 bit value 0x3f. However, the end of > string marker is actually variable length and as long as the first two > bits are written you can drop the rest. So the whole thing fits into > 4 bytes which is what is written. > > The code is this way because originally I did not realise that the > string terminator was effectively a two bit quantity ie. if the first > two bits are both 1 then the strings ends and you stop reading and > throw away any remaining part of the byte. You could probably write 2 > bits and then round the byte count up instead of writing 6 and > rounding down. > > ..Steve OK, I got this wrong. I thought the label section could be continously read. Every label ending with 0x3f and next label starting at next byte boundary.
- Previous message: [mkgmap-dev] [PATCH] Bug in label encoding
- Next message: [mkgmap-dev] Commit: r1565: Move natural=water to resolution=18
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the mkgmap-dev mailing list