private writeTextUsingEncoding ( string $text, integer $encodingNo ) | ||
$text | string | Text to print, UTF-8 format. |
$encodingNo | integer | Encoding number to use- assumed to exist. |
private function writeTextUsingEncoding($text, $encodingNo)
{
$encodeMap = $this->encode[$encodingNo];
$len = mb_strlen($text, self::INPUT_ENCODING);
$rawText = str_repeat(self::REPLACEMENT_CHAR, $len);
$j = 0;
for ($i = 0; $i < $len; $i++) {
$char = mb_substr($text, $i, 1, self::INPUT_ENCODING);
if (isset($encodeMap[$char])) {
$rawText[$j] = $encodeMap[$char];
} elseif (self::asciiCheck($char)) {
$rawText[$j] = $char;
} elseif ($char === "\r") {
/* Skip past Windows line endings (UTF-8 usage) */
continue;
}
$j++;
}
if ($this->printer->getCharacterTable() != $encodingNo) {
$this->printer->selectCharacterTable($encodingNo);
}
$this->writeTextRaw(substr($rawText, 0, $j));
}