Querying non-printable characters from the database

I want to save DPL labels, similar to ZPL, in MSSQL database for future retrieval and printing. My problem is the DPL string contains non-printable characters that are being stripped out of my query results, for example the STX delimiter (start of line) \x02.

I assume the characters are being stored properly based on copying the string from management studio and pasting into notepad++ shows the missing characters

image

However when I query the label string and print the results in ignition the STX delimiter is gone, however the end of line character is still present.

image

Any help is greatly appreciated!

Is this any help?

string = "\02n\r\n\02M0592\r\n\02O0220\r\n"
charArray = [c for c in string]
print(charArray)

# Returns:
# ['\x02', 'n', '\r', '\n', '\x02', 'M', '0', '5', '9', '2', '\r', '\n', '\x02', 'O', '0', '2', '2', '0', '\r', '\n']

STX is 0x02.

Try it in the script console.

Many things won't print visibly even though they are there. If in doubt, especially when charsets are involved, use byte arrays and blob columns.

1 Like

Yeah I noticed that. When I read the file from disk then print the results the characters in question aren’t visible, but they are still there. When I query them from the database and print them they just aren’t there period, but they are in the database.

I think your suggestion of reading the label file as a byte array and storing it that way might be the way to go.