SetaPDF_Core_Encoding A wrapper class for handling PDF specific encodings
File: /SetaPDF v2/Core/Encoding.php
This class is a wrapper around iconv/mb_*-functions to offer a transparent support of PDF specific and independent, unknown encodings.
By default the class will use mb functions if available. Otherwise it will fallback to iconv functions. To use specific functions just set the static property:
SetaPDF_Core_Encoding::setLibrary('mb'); // or SetaPDF_Core_Encoding::setLibrary('iconv');
Class hierarchy
Summary
Constants
MAC_EXPERT
MacExpertEncoding
MAC_ROMAN
MacRomanEncoding
MAX_EXPERT
WARNING: This constant is marked as deprecated!
PDF_DOC
PDFDocEncoding
STANDARD
StandardEncoding
SYMBOL
Symbol
WIN_ANSI
WinAnsiEncoding
ZAPF_DINGBATS
ZapfDingbats
Static Properties
$library
Library to use for conversion between encodings
Static Methods
convert()
Converts a string from one to another encoding.
A kind of wrapper around iconv/mb_convert_encoding plus the separate processing of PDF related encodings.
Parameters
- $string : string
The string to convert in $inEncoding
- $inEncoding : string
The "in"-encoding
- $outEncoding : string
The "out"-encoding
convertPdfString()
Converts a PDF string (in PDFDocEncoding or UTF-16BE) to another encoding.
This method automatically detects UTF-16BE encoding in the input string and removes the BOM.
Parameters
- $string : string
The string to convert in PDFDocEncoding or UTF-16BE
- $outEncoding : string
The "out"-encoding
fromUtf16Be()
Converts a string from UTF-16BE to another predefined encoding.
Parameters
- $table : array|SetaPDF_Core_Font_Cmap_CmapInterface
The translation table
- $string : string
The input string
- $ignore : boolean
Characters that cannot be represented in the target charset are silently discarded
- $translit : boolean
Transliteration activated
- $substituteChar : string
getLibrary()
Get the library to use for multibyte string operations.
If none is defined the method will check for the mbstring module and define it or iconv automatically.
getPredefinedEncodingTable()
Get the translation table of a predefined PDF specific encodings.
Parameters
- $encoding : string
Exceptions
Throws InvalidArgumentException
isPredefinedEncoding()
Checks if an encoding is a PDF specific predefined encoding.
Parameters
- $encoding : string
setLibrary()
Set the library to use for multibyte string operations.
Parameters
- $library : string
Possible values are 'mb' for mbstring functions or 'iconv' for iconv functions.
strSplit()
Splits a string into an array.
Parameters
- $string : string
- $encoding : string
strlen()
Get the length of a string in a specific encoding.
Parameters
- $string : string
- $encoding : string
substr()
Return part of a string.
Parameters
- $string : string
- $start : int
- $length : int
- $encoding : string
Return Values
Returns false on error
toPdfString()
Converts a string into PdfDocEncoding or UTF-16BE.
Actually directly converts to UTF-16BE to support unicode. Method should be optimized to choose the correct encoding (PdfDoc or UTF-16BE) depending on the characters used.
Parameters
- $string : string
- $inEncoding : string
toUtf16Be()
Converts a string to UTF-16BE from another predefined 1-byte encoding.
Parameters
- $table : array|SetaPDF_Core_Font_Cmap_CmapInterface
The translation table
- $string : string
The input string
- $ignore : boolean
Characters that cannot be represented in the target charset are silently discarded
- $translit : boolean
Transliteration activated