Code 93 (USS Code 93) 為 Code 39 的增強版,提供更高資料密度與安全性,字元集包含 43 個基本字元 (0-9, A-Z, - . space $ / + %) 加 5 個特殊字元,並內建兩個檢查碼 (C、K)。主要應用於加拿大郵政補充投遞資訊編碼。
程式碼引入 header.php 並定義字元集陣列 $keys,透過表格呈現可輸入字元按鈕與說明,最後呼叫 $table->draw() 輸出 HTML。核心邏輯如下:
<?php
define('IN_CB', true);
include('header.php');
$keys = array('0','1','2','3','4','5','6','7','8','9',
'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'-','.',' ','$','/','+','%');
$n = $table->numRows();
$table->insertRows($n, 3);
$table->addRowAttribute($n, 'class', 'table_title');
$table->addCellAttribute($n, 0, 'align', 'center');
$table->addCellAttribute($n, 0, 'colspan', '2');
$table->setText($n, 0, '<font color="#ffffff"><b>Specifics Configs</b></font>');
$table->setText($n+1, 0, 'Keys');
$text2display = '';
$c = count($keys);
for ($i = 0; $i < $c; $i++) {
$text2display .= '<input type="button" value="'.$keys[$i].'" style="width:25px" onclick="newkey(this.form,\''.$keys[$i].'\')" /> ';
}
$table->setText($n+1, 1, $text2display);
$table->setText($n+2, 0, 'Explanation');
$table->setText($n+2, 1, '<ul style="margin:0;padding-left:25px"><li>Known also as USS Code 93.</li><li>Higher density and data security enhancement to Code39.</li><li>Used by Canadian postal office.</li><li>43 chars + 5 special, 2 check digits (C and K).</li></ul>');
$table->draw();
include('footer.php');
?>
onclick 呼叫 newkey() (需於 header.php 定義) 將字元填入輸入欄位。$table 物件 (可能為 HTML_Table 或自訂類別),負責 HTML 組裝。<img src="..."> 為靜態示意圖,實際產生條碼圖片需搭配 GD 函式庫或 Zend_Barcode、Picqer\Barcode\BarcodeGeneratorPNG 等套件。| 方案 | 特點 |
|---|---|
picqer/php-barcode-generator | Composer 安裝、支援 Code 93/128/QR、無相依、效能佳 |
zendframework/zend-barcode | Zend Framework 元件、企業級、支援多種輸出格式 |
JS 前端生成 (JsBarcode) | 零後端負擔、適合純前端應用 |
本範例示範 Code 93 字元集與 UI 配置,實際專案建議採用成熟 Composer 套件產生向量/點陣圖,並依需求決定伺服端或客戶端渲染。