[sms] Fix two bugs regarding 7 bit coding...
- Fix the length (almost) - Move the second part by 8 - b_off e.g. with (ba) 0x62 0x61 the first bit of 0x61 goes to the highest on the first byte and the second word contains 0x110000... - The simple test case is almost passed... just a missing character at the end.
This commit is contained in:
parent
59da07bd0e
commit
3b1f3d0798
|
@ -54,8 +54,8 @@ u_int8_t *gsm_7bit_encode(const char *data, u_int8_t *out_length)
|
|||
|
||||
for (i = 0; i < length; ++i) {
|
||||
u_int8_t first = (data[i] & 0x7f) << b_off;
|
||||
u_int8_t second = (data[i] & 0x7f) >> (7 - b_off);
|
||||
|
||||
u_int8_t second = (data[i] & 0x7f) >> (8 - b_off);
|
||||
|
||||
result[d_off] |= first;
|
||||
if (second != 0)
|
||||
result[d_off + 1] = second;
|
||||
|
@ -68,7 +68,7 @@ u_int8_t *gsm_7bit_encode(const char *data, u_int8_t *out_length)
|
|||
}
|
||||
}
|
||||
|
||||
*out_length = d_off;
|
||||
*out_length = d_off + 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue