escpos-php
Public Member Functions | Public Attributes | Static Protected Member Functions | Protected Attributes | List of all members
Mike42\Escpos\CodePage Class Reference

Class to handle data about a particular CodePage, as loaded from the receipt print database. More...

Public Member Functions

 __construct ($id, array $codePageData)
 
 getDataArray ()
 Get a 128-entry array of unicode code-points from this code page. More...
 
 getIconv ()
 
 getId ()
 
 getName ()
 
 getNotes ()
 The notes may explain quirks about a code-page, such as a source if it's non-standard or un-encodeable. More...
 
 isEncodable ()
 

Public Attributes

const MISSING_CHAR_CODE = 0x20
 Value to use when no character is set. More...
 

Static Protected Member Functions

static generateEncodingArray (string $encodingName)
 Given an ICU encoding name, generate a 128-entry array, with the unicode code points for the character at positions 128-255 in this code page. More...
 

Protected Attributes

 $data
 Data string, null if not known (can be computed with iconv)
 
 $iconv
 Iconv encoding name, null if not known.
 
 $id
 Internal ID of the CodePage.
 
 $name
 Name of the code page. More...
 
 $notes
 Notes on this code page, or null if not set.
 

Detailed Description

Class to handle data about a particular CodePage, as loaded from the receipt print database.

Also computes map between UTF-8 and this encoding if necessary, using the intl library.

Constructor & Destructor Documentation

◆ __construct()

Mike42\Escpos\CodePage::__construct (   $id,
array  $codePageData 
)
Parameters
string$idUnique internal identifier for the CodePage.
array$codePageDataAssociative array of CodePage data, as specified by the upstream receipt-print-hq/escpos-printer-db database. May contain 'name', 'data', 'iconv', and 'notes' fields.

Member Function Documentation

◆ generateEncodingArray()

static Mike42\Escpos\CodePage::generateEncodingArray ( string  $encodingName)
staticprotected

Given an ICU encoding name, generate a 128-entry array, with the unicode code points for the character at positions 128-255 in this code page.

Parameters
string$encodingNameName of the encoding
Returns
array 128-entry array of code points

◆ getDataArray()

Mike42\Escpos\CodePage::getDataArray ( )

Get a 128-entry array of unicode code-points from this code page.

Exceptions
InvalidArgumentExceptionWhere the data is now known or computable.
Returns
array Data for this encoding.

◆ getIconv()

Mike42\Escpos\CodePage::getIconv ( )
Returns
string|null Iconv encoding name, or null if not set.

◆ getId()

Mike42\Escpos\CodePage::getId ( )
Returns
string Unique identifier of the code page.

◆ getName()

Mike42\Escpos\CodePage::getName ( )
Returns
string Name of the code page.

◆ getNotes()

Mike42\Escpos\CodePage::getNotes ( )

The notes may explain quirks about a code-page, such as a source if it's non-standard or un-encodeable.

Returns
string|null Notes on the code page, or null if not set.

◆ isEncodable()

Mike42\Escpos\CodePage::isEncodable ( )
Returns
boolean True if we can encode with this code page (ie, we know what data it holds).

Many printers contain vendor-specific code pages, which are named but have not been identified or typed out. For our purposes, this is an "un-encodeable" code page.

Member Data Documentation

◆ $name

string Mike42\Escpos\CodePage::$name
protected

Name of the code page.

Substituted with the ID if not set.

◆ MISSING_CHAR_CODE

const Mike42\Escpos\CodePage::MISSING_CHAR_CODE = 0x20

Value to use when no character is set.

This is a space in ASCII.


The documentation for this class was generated from the following file: