Skip to content

Commit

Permalink
Fix wrong calculation of array by using wrong data type (char instead…
Browse files Browse the repository at this point in the history
… of unichar).
  • Loading branch information
benjohnde committed Sep 21, 2020
1 parent b612c6d commit 5267eb7
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ + (BOOL)decodeC40Segment:(ZXBitSource *)bits result:(NSMutableString *)result {
case 0:
if (cValue < 3) {
shift = cValue + 1;
} else if (cValue < sizeof(C40_BASIC_SET_CHARS) / sizeof(char)) {
} else if (cValue < sizeof(C40_BASIC_SET_CHARS) / sizeof(unichar)) {
unichar c40char = C40_BASIC_SET_CHARS[cValue];
if (upperShift) {
[result appendFormat:@"%C", (unichar)(c40char + 128)];
Expand All @@ -243,7 +243,7 @@ + (BOOL)decodeC40Segment:(ZXBitSource *)bits result:(NSMutableString *)result {
shift = 0;
break;
case 2:
if (cValue < sizeof(C40_SHIFT2_SET_CHARS) / sizeof(char)) {
if (cValue < sizeof(C40_SHIFT2_SET_CHARS) / sizeof(unichar)) {
unichar c40char = C40_SHIFT2_SET_CHARS[cValue];
if (upperShift) {
[result appendFormat:@"%C", (unichar)(c40char + 128)];
Expand Down Expand Up @@ -308,7 +308,7 @@ + (BOOL)decodeTextSegment:(ZXBitSource *)bits result:(NSMutableString *)result {
case 0:
if (cValue < 3) {
shift = cValue + 1;
} else if (cValue < sizeof(TEXT_BASIC_SET_CHARS) / sizeof(char)) {
} else if (cValue < sizeof(TEXT_BASIC_SET_CHARS) / sizeof(unichar)) {
unichar textChar = TEXT_BASIC_SET_CHARS[cValue];
if (upperShift) {
[result appendFormat:@"%C", (unichar)(textChar + 128)];
Expand Down Expand Up @@ -349,7 +349,7 @@ + (BOOL)decodeTextSegment:(ZXBitSource *)bits result:(NSMutableString *)result {
shift = 0;
break;
case 3:
if (cValue < sizeof(TEXT_SHIFT3_SET_CHARS) / sizeof(char)) {
if (cValue < sizeof(TEXT_SHIFT3_SET_CHARS) / sizeof(unichar)) {
unichar textChar = TEXT_SHIFT3_SET_CHARS[cValue];
if (upperShift) {
[result appendFormat:@"%C", (unichar)(textChar + 128)];
Expand Down

0 comments on commit 5267eb7

Please sign in to comment.