Class JavaScriptCodec

(line 36)



Located in File: /codecs/JavaScriptCodec.php

Reference implementation of the JavaScriptCodec codec.

Class Variables


Class Constants


Method Detail

JavaScriptCodec __construct ()
void decodeCharacter ( $input)
void encodeCharacter ( $immune,  $c)

Constructor __construct (line 41)

JavaScriptCodec __construct( )

Overrides : Codec::__construct() Populates the $hex map of non-alphanumeric single-byte characters.

Public Constructor


Method decodeCharacter (line 121)

void decodeCharacter( $input)

Returns the decoded version of the character starting at index, or null if no decoding is possible.

See Formats all are legal both upper/lower case: \\a - special characters \\xHH \\uHHHH \\OOO (1, 2, or 3 digits)


  • $input:


  • access - public

Method encodeCharacter (line 55)

void encodeCharacter( $immune, $c)

Overrides : Codec::encodeCharacter() Encode a Character with a Codec.

Returns backslash encoded numeric format. Does not use backslash character escapes such as, \" or \' as these may cause parsing problems.

For example, if a javascript attribute, such as onmouseover, contains a \" that will close the entire attribute and allow an attacker to inject another script attribute.


  • $immune:
  • $c:


  • access - public

Inherited Variables

Inherited Class Variable Summary

Inherited Methods

Inherited Method Summary

Inherited From Class Codec

Codec::__construct() - Populates the $hex map of non-alphanumeric single-byte characters.

Codec::containsCharacter() - Utility to search a char[] for a specific char.

Codec::decode() - Decode a String that was encoded using the encode method in this Class

Codec::detectEncoding() - Utility to detect a (potentially multibyte) string's encoding with extra logic to deal with single characters that mb_detect_encoding() fails upon.

Codec::encode() - Encode a String with a Codec.

Codec::encodeCharacter() - Encode a Character with a Codec.

Codec::forceToSingleCharacter() - Utility to get first (potentially multibyte) character from a (potentially multicharacter) multibyte string.

Codec::getHexForNonAlphanumeric() - Returns the ordinal value as a hex string of any character that is not a single-byte alphanumeric. The character should be supplied as a string in the UTF-32 character encoding.

Codec::isHexDigit() - Utility method to determine if a single character string is a hex digit

Codec::normalizeEncoding() - Utility to normalize a string's encoding to UTF-32.

Codec::toHex() - Return the hex value of a character as a string without leading zeroes.

Documentation generated on Fri, 21 May 2010 14:53:39 -0400 by phpDocumentor 1.4.3