In many cases, our users may need to insert special characters like carriage returns and functions into their barcodes. Each symbology’s ISO standards dictate which characters can be encoded into a barcode and these characters are outlined on our website under each symbology’s respective user manual page. For a step-by-step guide to choosing the correct type of barcode for your project, have a look at our previous post, Choosing the Right Barcode.
How to Insert Special Characters with ASCII Codes
Many special characters can be encoded using Barcode Bakery simply by using PHP’s chr function. The decimal code associated with each special character can be located using an ASCII table and then passed to the function. For example, to insert a carriage return, you’ll want to use chr(13) as follows:
$code->parse(“hello” . chr(13) . “new line”);
This use of the carriage return is useful when a barcode will be scanned to populate a single-input multi-line form such as a text area. If a tab character is required, such as when a barcode will be scanned to populate a form with multiple text inputs, then chr(9) would be used.
How to Insert FNC1 with setTilde()
For certain symbologies such as DataMatrix that allow the FNC1 character, the setTilde() method should be used. By setting its value to true, the tilde character can then be used to insert FNC1 by inserting ~F into a string. This character is used in most cases to enter a different mode specific to each barcode type.
To find more information about which barcode symbologies can accommodate the special characters you require, check out our user guides in the resources found on our website: http://www.barcodebakery.com/en/resources