'How to print caret(^) character in Zebra Programming Language?
Using version: ZPL2.
Format prefix: ^.
Can someone please help how to print caret(^) character using ZPL II. Either we need some escape sequence or any other way of printing this Format Prefix(^) as a normal character.
Note: Don't want to change the format prefix(^) to some other character.
Any help would be highly appreciated.
Solution 1:[1]
You need to use ^FH before your ^FD and then use the hex value of the caret : _5E
^XA
^FO100,100
^AD^FH
^FDCaret _5e used for HEX^FS
^XZ
See also : How to print a tilde (~) in Zebra Programming Language (ZPL)
Solution 2:[2]
You can try to change format prefix of ZPL code which is ^ into different one ex. ¬ using ^CC. After print command, reverse the change back to ^.
^XA
^CC¬
¬FO30,20¬FD_AB534^H¬FS
¬CC^
^XZ
The ^FH and _5e solution is also good but will not work in all cases. If you use ^FH command it will convert everything which appear to be hex value
example - you want to print wifi password which is: _AB534^H. Normally you would use code:
^XA
^FO50,50
^FD_AB534^H^FS
^XZ
this code will print only:_AB534
with ^FH command and replacing ^ with _5E will look like:
^XA
^FO50,50
^FH^FD_AB534_5EH^FS
^XZ
it prints: ½534^H
Password is different than _AB534^H. this is because ^FH reads _AB as a HEX value and converts it as well
using this code:
^XA
^CC¬
¬FO30,20¬FD_AB534^H¬FS
¬CC^
^XZ
output is:_AB534^H
sign ¬ can not be entered simply from keyboard (without alt+ combination) so will not be used in wifi passwords.
Solution 3:[3]
Another option is to escape "_" as "_5f" and then escape "^" as "_5e". This protects against accidental decoding of a string already containing "_" without encoding every single character in ^FD, ^FV or ^SN commands.
In c#, this would be:
return value.Replace("_", "_5f").Replace("^", "_5e");
This is not the most efficient code, but is concise.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | dns |
| Solution 3 | user2480117 |
