mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Correction to Base256 encoding
This commit is contained in:
parent
8bdb2e28a4
commit
e527c45c2d
@ -382,20 +382,26 @@ char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl, char *enco
|
|||||||
case 'b': // Binary
|
case 'b': // Binary
|
||||||
{
|
{
|
||||||
int l = 0; // how much to encode
|
int l = 0; // how much to encode
|
||||||
|
int temp;
|
||||||
if (encoding) {
|
if (encoding) {
|
||||||
int p;
|
int p;
|
||||||
for (p = sp; p < sl && tolower(encoding[p]) == 'b'; p++)
|
for (p = sp; p < sl && tolower(encoding[p]) == 'b'; p++)
|
||||||
l++;
|
l++;
|
||||||
}
|
}
|
||||||
t[tp++] = 231; // base256
|
t[tp++] = 231; // base256
|
||||||
if (l < 250)
|
if (l < 250) {
|
||||||
t[tp++] = l;
|
t[tp] = l + (((tp + 1) * 149) % 255) + 1; tp++;
|
||||||
else {
|
} else {
|
||||||
t[tp++] = 249 + (l / 250);
|
t[tp] = (249 + (l / 250)) + (((tp + 1) * 149) % 255) + 1; tp++;
|
||||||
t[tp++] = (l % 250);
|
t[tp] = (l % 250) + (((tp + 1) * 149) % 255) + 1; tp++;
|
||||||
}
|
}
|
||||||
while (l-- && tp < tl) {
|
while (l-- && tp < tl) {
|
||||||
t[tp] = s[sp++] + (((tp + 1) * 149) % 255) + 1; // see annex H
|
temp = s[sp++] + (((tp + 1) * 149) % 255) + 1; // see annex H
|
||||||
|
if(temp <= 255) {
|
||||||
|
t[tp] = temp;
|
||||||
|
} else {
|
||||||
|
t[tp] = temp - 256;
|
||||||
|
}
|
||||||
tp++;
|
tp++;
|
||||||
}
|
}
|
||||||
enc = 'a'; // reverse to ASCII at end
|
enc = 'a'; // reverse to ASCII at end
|
||||||
|
Loading…
Reference in New Issue
Block a user