Decompiler: allow UTF-8 strings
This commit is contained in:
parent
9dd3893b1a
commit
c62abcbe2e
|
@ -228,7 +228,8 @@ class Decompiler_Value extends Decompiler_Object // {{{
|
|||
$code = var_export($this->value, true);
|
||||
if (gettype($this->value) == 'string') {
|
||||
$code = preg_replace_callback("![\t\r\n]+!", array(&$this, 'convertNewline'), $code);
|
||||
$code = preg_replace_callback("![\\x01-\\x1f\\x7f-\\xff]+!", array(&$this, 'escape8BitString'), $code);
|
||||
$code = preg_replace_callback("![\\x01-\\x1f]+!", array(&$this, 'escapeString'), $code);
|
||||
$code = preg_replace_callback("![\\x7f-\\xff]+!", array(&$this, 'escape8BitString'), $code);
|
||||
$code = preg_replace("!^'' \\. \"|\" \\. ''\$!", '"', $code);
|
||||
}
|
||||
return $code;
|
||||
|
@ -241,7 +242,14 @@ class Decompiler_Value extends Decompiler_Object // {{{
|
|||
|
||||
function escape8BitString($m)
|
||||
{
|
||||
// TODO: recognize $encoding
|
||||
if (function_exists("iconv") && @iconv("UTF-8", "UTF-8//IGNORE", $m[0]) == $m[0]) {
|
||||
return $m[0];
|
||||
}
|
||||
return $this->escapeString($m);
|
||||
}
|
||||
|
||||
function escapeString($m)
|
||||
{
|
||||
$s = $m[0];
|
||||
$escaped = '';
|
||||
for ($i = 0, $c = strlen($s); $i < $c; ++$i) {
|
||||
|
|
Loading…
Reference in New Issue