getSupportedCodePages(); $first = true; // Print larger table for first code-page. foreach($codePages as $table => $name) { /* Change printer code page */ $printer -> selectCharacterTable(255); $printer -> selectCharacterTable($table); /* Select & print a label for it */ $label = $name; if($name === false) { $label= " (not matched to iconv table)"; } $printer -> setEmphasis(true); $printer -> textRaw("Table $table: $label\n"); $printer -> setEmphasis(false); if($name === false && !$verbose) { continue; // Skip non-recognised } /* Print a table of available characters (first table is larger than subsequent ones */ if($first) { $first = false; compactCharTable($printer, 1, true); } else { compactCharTable($printer); } } $printer -> cut(); $printer -> close(); function compactCharTable($printer, $start = 4, $header = false) { /* Output a compact character table for the current encoding */ $chars = str_repeat(' ', 256); for($i = 0; $i < 255; $i++) { $chars[$i] = ($i > 32 && $i != 127) ? chr($i) : ' '; } if($header) { $printer -> setEmphasis(true); $printer -> textRaw(" 0123456789ABCDEF0123456789ABCDEF\n"); $printer -> setEmphasis(false); } for($y = $start; $y < 8; $y++) { $printer -> setEmphasis(true); $printer -> textRaw(strtoupper(dechex($y * 2)) . " "); $printer -> setEmphasis(false); $printer -> textRaw(substr($chars, $y * 32, 32) . "\n"); } }