如何用星微米SDK打印€符号?

时间:2014-06-18 23:42:57

标签: ios

我有星微米级tsp650和我在我的应用程序中实现SDK,但我不能打印€符号

有人知道打印它的代码是什么?

由于

2 个答案:

答案 0 :(得分:2)

最后STAR MICRONICS支持回答我

打印€符号的代码是

[commands appendBytes:"\x1b\x1d\x74\x04"
               length:sizeof("\x1b\x1d\x74\x04")-1]; //meto Euro

[commands appendBytes:"\xD5"
               length:sizeof("\xD5")-1]; //meto euro

答案 1 :(得分:0)

€以十六进制字节值表示:
UTF16:20AC
UTF8:E2 82 AC

char utf8[]  = "\xE2\x82\xac";
char utf16[] = "\x20\xAC";
NSLog(@"utf8:  %@", [[NSString alloc] initWithBytes:utf8 length:3 encoding:NSUTF8StringEncoding]);
NSLog(@"utf16: %@", [[NSString alloc] initWithBytes:utf16 length:2 encoding:NSUTF16BigEndianStringEncoding]);

NSString *cost = @"156.95 \xE2\x82\xac\r\n"; // dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"Cost: %@", cost);

NSMutableData *commands = [NSMutableData new];
[commands appendData:[@"156.95 \xE2\x82\xac\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"commands: %@", commands);

NSLog输出:

utf8:  €  
utf16: €  
cost: 156.95 €   
commands: <3135362e 393520e2 82ac0d0a>