//Strip BOM characters from the source
$this->
stripBOM($source,
$encoding);
//Convert to UTF8 if needed
if ($encoding && !
preg_match("/UTF-?8/i",
$encoding)) { $source =
mb_convert_encoding($source, "UTF-8",
$encoding);
} //Instead of using mb_substr for each character, split the source
//into an array of UTF8 characters for performance reasons
$this->source = Utils::
stringToUTF8Array( $source,
!
isset($options["strictEncoding"
]) ||
$options["strictEncoding"
] );
$this->length =
count($this->source
);
//Convert character codes to UTF8 characters in whitespaces and line
//terminators
$this->lineTerminators =
array_merge( self::
$lineTerminatorsSequences, self::
$lineTerminatorsChars );
foreach (array
("whitespaces", "lineTerminators"
) as $key) {