PHP Класс HTMLPurifier_Encoder, yii

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
cleanUTF8 ( string $str, boolean $force_php = false ) : string Cleans a UTF-8 string for well-formedness and SGML validity
convertFromUTF8 ( string $str, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : string Converts a string from UTF-8 based on configuration.
convertToASCIIDumbLossless ( string $str ) : string Lossless (character-wise) conversion of HTML to ASCII
convertToUTF8 ( string $str, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : string Convert a string to UTF-8 based on configuration.
iconv ( string $in, string $out, string $text, integer $max_chunk_size = 8000 ) : string iconv wrapper which mutes errors and works around bugs.
iconvAvailable ( ) : boolean
muteErrorHandler ( ) Error-handler that mutes errors, alternative to shut-up operator.
testEncodingSupportsASCII ( string $encoding, boolean $bypass = false ) : Array This expensive function tests whether or not a given character encoding supports ASCII. 7/8-bit encodings like Shift_JIS will fail this test, and require special processing. Variable width encodings shouldn't ever fail.
testIconvTruncateBug ( ) : integer glibc iconv has a known bug where it doesn't handle the magic IGNORE stanza correctly. In particular, rather than ignore characters, it will return an EILSEQ after consuming some number of characters, and expect you to restart iconv as if it were an E2BIG. Old versions of PHP did not respect the errno, and returned the fragment, so as a result you would see iconv mysteriously truncating output. We can work around this by manually chopping our input into segments of about 8000 characters, as long as PHP ignores the error code. If PHP starts paying attention to the error code, iconv becomes unusable.
unichr ( $code ) +----------+----------+----------+----------+
unsafeIconv ( string $in, string $out, string $text ) : string iconv wrapper which mutes errors, but doesn't work around bugs.

Приватные методы

Метод Описание
__construct ( ) Constructor throws fatal error if you attempt to instantiate class

Описание методов

cleanUTF8() публичный статический Метод

It will parse according to UTF-8 and return a valid UTF8 string, with non-SGML codepoints excluded.
public static cleanUTF8 ( string $str, boolean $force_php = false ) : string
$str string The string to clean
$force_php boolean
Результат string

convertFromUTF8() публичный статический Метод

Converts a string from UTF-8 based on configuration.
public static convertFromUTF8 ( string $str, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : string
$str string The string to convert
$config HTMLPurifier_Config
$context HTMLPurifier_Context
Результат string

convertToASCIIDumbLossless() публичный статический Метод

Lossless (character-wise) conversion of HTML to ASCII
public static convertToASCIIDumbLossless ( string $str ) : string
$str string UTF-8 string to be converted to ASCII
Результат string ASCII encoded string with non-ASCII character entity-ized

convertToUTF8() публичный статический Метод

Convert a string to UTF-8 based on configuration.
public static convertToUTF8 ( string $str, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : string
$str string The string to convert
$config HTMLPurifier_Config
$context HTMLPurifier_Context
Результат string

iconv() публичный статический Метод

iconv wrapper which mutes errors and works around bugs.
public static iconv ( string $in, string $out, string $text, integer $max_chunk_size = 8000 ) : string
$in string Input encoding
$out string Output encoding
$text string The text to convert
$max_chunk_size integer
Результат string

iconvAvailable() публичный статический Метод

public static iconvAvailable ( ) : boolean
Результат boolean

muteErrorHandler() публичный статический Метод

Error-handler that mutes errors, alternative to shut-up operator.
public static muteErrorHandler ( )

testEncodingSupportsASCII() публичный статический Метод

This expensive function tests whether or not a given character encoding supports ASCII. 7/8-bit encodings like Shift_JIS will fail this test, and require special processing. Variable width encodings shouldn't ever fail.
public static testEncodingSupportsASCII ( string $encoding, boolean $bypass = false ) : Array
$encoding string Encoding name to test, as per iconv format
$bypass boolean Whether or not to bypass the precompiled arrays.
Результат Array of UTF-8 characters to their corresponding ASCII, which can be used to "undo" any overzealous iconv action.

testIconvTruncateBug() публичный статический Метод

glibc iconv has a known bug where it doesn't handle the magic IGNORE stanza correctly. In particular, rather than ignore characters, it will return an EILSEQ after consuming some number of characters, and expect you to restart iconv as if it were an E2BIG. Old versions of PHP did not respect the errno, and returned the fragment, so as a result you would see iconv mysteriously truncating output. We can work around this by manually chopping our input into segments of about 8000 characters, as long as PHP ignores the error code. If PHP starts paying attention to the error code, iconv becomes unusable.
public static testIconvTruncateBug ( ) : integer
Результат integer Error code indicating severity of bug.

unichr() публичный статический Метод

+----------+----------+----------+----------+
public static unichr ( $code )

unsafeIconv() публичный статический Метод

iconv wrapper which mutes errors, but doesn't work around bugs.
public static unsafeIconv ( string $in, string $out, string $text ) : string
$in string Input encoding
$out string Output encoding
$text string The text to convert
Результат string