PHP 클래스 HTMLPurifier_Encoder, yii

파일 보기 프로젝트 열기: yiisoft/yii 1 사용 예제들

공개 메소드들

메소드 설명
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