objective c - ASCII Code to NSData -


i'm trying figure out esc/pos commands , need code "gs" (ascii code 29) put nsdata.

currently can put strings want print without problems using code:

nsstring *str = @"text want print"; nsdata *data = [str datausingencoding:nsasciistringencoding]; 

is there easy way using either c++ or obj-c?

c, c++, , objective-c let put arbitrary ascii codes string using so-called escape sequences.

escape sequence start either in \x followed 2 hex digits, or \0 followed 3 octal digits.

ascii gs 29 in decimal or 1d in hex, can put gs in nsdata this:

nsdata *data = [@"\x1d" datausingencoding:nsasciistringencoding]; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -