I'm in a struggle with the encoding of characters with Zebra Printer.
I'm using ZebraDesigner and, for instance, I create a line with the text "Texte accentué". In the generated .prn file, the line is as follows : ^FT27,67^A0N,28,28^FH\^FDTexte accentu\82^FS
I'm guessing \82 is the encoded version of my letter é, but I don't find any relashionship between them two.
Any help would be welcome.
Ok, I got through it : 0x82 (Hexa) or 130 (Dec) is the encoding for "é" in extended ASCII (Codepages 437 or 850 : http://www.ascii-codes.com/)
To convert my string, I have to use this PHP function :
$text = iconv('UTF-8', 'CP437//TRANSLIT', $text); // Also works with CP850
I finally made this little script, which converts only extended ASCII characters (Decimal code >= 128), as the basic ones are correctly understood, and I wanted my function to be run with the full file as an argument.
function zebraConvert($text)
{
$return = '';
$arr = str_split(iconv('UTF-8', 'CP437//TRANSLIT', $text));
foreach ($arr as $char) {
$ord = ord($char);
if ($ord >= 128) {
$return .= '\\' . dechex($ord);
} else {
$return .= $char;
}
}
return $return;
}