Open Monograph Press  3.3.0
PhpXmlRpc\Helper\Charset Class Reference

Public Member Functions

 encodeEntities ($data, $srcEncoding='', $destEncoding='')
 
 getEntities ($charset)
 
 isValidCharset ($encoding, $validList)
 

Static Public Member Functions

static instance ()
 

Protected Attributes

 $charset_supersets
 
 $xml_iso88591_Entities = array("in" => array(), "out" => array())
 

Static Protected Attributes

static $instance = null
 

Detailed Description

Definition at line 7 of file Charset.php.

Member Function Documentation

◆ encodeEntities()

PhpXmlRpc\Helper\Charset::encodeEntities (   $data,
  $srcEncoding = '',
  $destEncoding = '' 
)

Convert a string to the correct XML representation in a target charset To help correct communication of non-ascii chars inside strings, regardless of the charset used when sending requests, parsing them, sending responses and parsing responses, an option is to convert all non-ascii chars present in the message into their equivalent 'charset entity'. Charset entities enumerated this way are independent of the charset encoding used to transmit them, and all XML parsers are bound to understand them. Note that in the std case we are not sending a charset encoding mime type along with http headers, so we are bound by RFC 3023 to emit strict us-ascii.

Todo:

do a bit of basic benchmarking (strtr vs. str_replace)

make usage of iconv() or recode_string() or mb_string() where available

Parameters
string$data
string$srcEncoding
string$destEncoding
Returns
string

Definition at line 90 of file Charset.php.

References PhpXmlRpc\PhpXmlRpc\$xmlrpc_internalencoding.

◆ getEntities()

PhpXmlRpc\Helper\Charset::getEntities (   $charset)

Used only for backwards compatibility

Deprecated:
Parameters
string$charset
Returns
array
Exceptions

Definition at line 251 of file Charset.php.

References PhpXmlRpc\Helper\Charset\$xml_iso88591_Entities.

◆ instance()

static PhpXmlRpc\Helper\Charset::instance ( )
static

This class is singleton for performance reasons.

Returns
Charset

Definition at line 43 of file Charset.php.

References PhpXmlRpc\Helper\Charset\$instance.

Referenced by PhpXmlRpc\PhpXmlRpc\exportGlobals().

◆ isValidCharset()

PhpXmlRpc\Helper\Charset::isValidCharset (   $encoding,
  $validList 
)

Checks if a given charset encoding is present in a list of encodings or if it is a valid subset of any encoding in the list.

Parameters
string$encodingcharset to be tested
string | array$validListcomma separated list of valid charsets (or array of charsets)
Returns
bool

Definition at line 221 of file Charset.php.

Field Documentation

◆ $charset_supersets

PhpXmlRpc\Helper\Charset::$charset_supersets
protected
Initial value:
= array(
'US-ASCII' => array('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8',
'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-12',
'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8',
'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN',),
)
Todo:
add to iso table the characters from cp_1252 range, i.e. 128 to 159? These will NOT be present in true ISO-8859-1, but will save the unwary windows user from sending junk (though no luck when receiving them...)

Definition at line 28 of file Charset.php.

◆ $instance

PhpXmlRpc\Helper\Charset::$instance = null
staticprotected

Definition at line 36 of file Charset.php.

Referenced by PhpXmlRpc\Helper\Charset\instance().

◆ $xml_iso88591_Entities

PhpXmlRpc\Helper\Charset::$xml_iso88591_Entities = array("in" => array(), "out" => array())
protected

Definition at line 10 of file Charset.php.

Referenced by PhpXmlRpc\Helper\Charset\getEntities().


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