Zebra打印机和字符编码
我在使用Zebra Printer进行字符编码时遇到困难。
I'm in a struggle with the encoding of characters with Zebra Printer.
我使用ZebraDesigner,例如,我创建了一行文本Texteaccentué。
在生成的.prn文件中,行如下所示:
^ FT27,67 ^ A0N,28,28 ^ FH \ ^ FDTexte accentu\82 ^ FS
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
我猜猜\82是我的信é的编码版本,但我没有找到它们之间的任何关系。
I'm guessing \82 is the encoded version of my letter é, but I don't find any relashionship between them two.
$ p
Any help would be welcome.
好的,我通过它:
0x82(Hexa)或130 Dec)是扩展ASCII中的é的编码(代码页437或850: http://www.ascii-
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/)
要转换我的字符串,我必须使用这个PHP函数:
To convert my string, I have to use this PHP function :
$text = iconv('UTF-8', 'CP437//TRANSLIT', $text); // Also works with CP850
我终于做了这个小脚本,只转换扩展ASCII字符代码> = 128),因为基本的正确理解,我希望我的函数以完整的文件作为参数运行。
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;
}