forked from netshade/Cocoa-Touch-Barcodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNKDIndustrialTwoOfFiveBarcode.m
executable file
·39 lines (33 loc) · 1.68 KB
/
NKDIndustrialTwoOfFiveBarcode.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// -----------------------------------------------------------------------------------
// NKDIndustrialTwoOfFiveBarcode.m
// -----------------------------------------------------------------------------------
// Created by Jeff LaMarche on Fri May 10 2002.
// �2002 Naked Software. All rights reserved.
// -----------------------------------------------------------------------------------
// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
// -----------------------------------------------------------------------------------
// You may use and redistribute this source code without limitation
// -----------------------------------------------------------------------------------
#import "NKDIndustrialTwoOfFiveBarcode.h"
@implementation NKDIndustrialTwoOfFiveBarcode
// -----------------------------------------------------------------------------------
-(NSString *)barcode
// -----------------------------------------------------------------------------------
{
int i,j;
char *barcode;
NSMutableString *theReturn = [NSMutableString stringWithString:@""];
// Include the checkdigit if appropriate
NSMutableString *encodeTemp = (checkDigit == -1) ? [NSMutableString stringWithString:content]
: [NSMutableString stringWithFormat:@"%@%c", content, checkDigit];
barcode = (char *)[encodeTemp cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(barcode); i++)
{
for (j=0;j<5;j++)
{
[theReturn appendString:([self _getBarForDigit:barcode[i] forBarNumber:j] == NARROW_BAR) ? @"100" : @"11100"];
}
}
return theReturn;
}
@end