\Nano4\UtilsUTF8XML

Convert everything from UTF-8 into an NCR[numeric character reference]

Borrowed from http://php.net/manual/en/function.htmlentities.php Thanks to user "montana" for this unique solution.

This has been enhanced with several extra features as were required during development of systems using Unicode with XML.

I've also reformatted and renamed all of the original methods.

Summary

Methods
Properties
Constants
encode()
encode_xml_chars()
fix_ampersand()
to_array()
encode_utf8_char()
decode()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

encode()

encode(string  $content, boolean  $quotes = false) : string

Encode a Unicode string to an XML document using NCR.

Parameters

string $content

The unicode string to encode.

boolean $quotes

Optional. Encode quote characters.

Returns

string —

The encoded string.

encode_xml_chars()

encode_xml_chars(string  $string, boolean  $quotes = false) : string

An alternative to html_entity_encode used internally.

Parameters

string $string

The string to encode.

boolean $quotes

Optional. Encode quote characters.

Returns

string —

The encoded string.

fix_ampersand()

fix_ampersand(string  $string) : string

Encode any ampersand characters which are not entities.

Parameters

string $string

String to encode.

Returns

string —

The encoded string.

to_array()

to_array(string  $string) : array

Convert a unicode string into an array.

Parameters

string $string

String to convert.

Returns

array —

The array representing the string.

encode_utf8_char()

encode_utf8_char(string  $c) : string

Replace a UTF8 character with a NCR.

Parameters

string $c

The character to replace.

Returns

string —

The NCR string representing the character.

decode()

decode(string  $content) : string

Decode a previously encoded string.

Parameters

string $content

An XML string.

Returns

string —

A UTF-8 string.