VB.net sending accented characters over TCP

I am working on a project for a client using a VB.net app that sends a ZPL command string over a TCP connection using StreamWriter. They recently want to have labels that contain accented characters/ foreign characters, but when the streamwriter sends these foreign characters the data is being corrupted in transit somehow and the resulting print has mangled output. In my testing, if I copy the ZPL string and send it to the printer using the Zebra direct communications tool, the print turns out just fine. Using Wireshark to monitor the data sent to the printer shows that the data being sent by the Streamwriter is different than the data sent by the Zebra tool, so clearly something is happening with the translation of the accented characters when sent by the streamwriter, but I have not been able to figure out what the cause is, or how to fix it. One thing I did try was to import the Zebra SDK tools and replace the existing code with Zebra library methods to send the data, but that has the same garbled result.

Has anyone experienced this issue before?

Attached is an image of two printed labels, the bottom label has the correct accented characters resulting from a send via direct communication tool, the top label has the garbled characters resulting from a send via my clients app.

Attachments: 
Steven Si
This sounds like an encoding

This sounds like an encoding issue. When you send the *accented* characters from the application, you need to make sure that they are correctly encoded. ZPL accepts unicode encoding. Try UTF-8 or UTF-16.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Eric Stanley
The streamwriter defaults to

The streamwriter defaults to UTF-8 encoding, but to be sure I also tried pretty much every other option for encoding to no success. I even tried converting the string to a byte array using UTF-8 encoding and sending the byte stream instead of a string, but that also did not work.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steven Si
Check out the Zebra Code Page

Check out the Zebra Code Page in the ZPL Programming Guide for the correct encoding of the accented characters. Sometime, the software editor in IDE may use a different encoding scheme, which could cause the incompatibility. Try to pick up one accented character's encoding from the code page and send the data to the printer from the application. 

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments