2

i have star micronics tsp650 and im implementing SDK in my app, but i cant print the € symbol

someone knows what is the code to print it?

Thanks

2 Answers2

2

Finally STAR MICRONICS support answer me

the code to print € symbol is

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

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

€ in hex byte values:
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 output:

utf8:  €  
utf16: €  
cost: 156.95 €   
commands: <3135362e 393520e2 82ac0d0a>
zaph
  • 111,848
  • 21
  • 189
  • 228
  • but how to put? \x20ac? or \xe282ac? – Miguel Angel Expósito Jun 18 '14 at 23:49
  • Dont works, here is my code: [commands appendData:[@"156.95 \xE2, \x82, \xac \x20, \xAC \r\n" dataUsingEncoding:NSASCIIStringEncoding]]; – Miguel Angel Expósito Jun 18 '14 at 23:59
  • nope :( still doesnt works, with UTF8 dont print the symbol, with utf16 error conversion to input utf8 Maybe is some other ascii code? – Miguel Angel Expósito Jun 19 '14 at 00:10
  • I have added the code you are using as an example. The Euro symbol can not be represented in ASCII so NSASCIIStringEncoding can not be used, NSUTF8StringEncoding must be used. Also only utf8 hex can be used in string literals, not utf16 or utf32. – zaph Jun 19 '14 at 00:31
  • If i put: [commands appendData:[@"156.95 \xE2\x82\xac \r\n" dataUsingEncoding:NSUTF8StringEncoding]]; It print another extrange symbol, maybe is printer encription problem – Miguel Angel Expósito Jun 19 '14 at 13:57
  • Yeah, it must be a printer issue. Here is a link to how to [enable the character viewer](http://stackoverflow.com/a/24204168/451475), it will allow you to see the codes for all the unicode characters. – zaph Jun 19 '14 at 15:38