function utf8converter_decode_utf8($what, $to_encoding)
{
    if (!utf8converter_can_convert_encoding($from_encoding)) {
        return false;
    }
    // if
    if (!$what) {
        return '';
    }
    // if
    $converter = new UTF8Converter($to_encoding);
    return $converter->utf8ToStr($what);
}
Exemplo n.º 2
0
                        // Counts single quotes that are preceded by an odd number of backslashes,
                        // which means theyre escaped quotes.
                        $escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
                        $unescaped_quotes = $total_quotes - $escaped_quotes;
                        if ($unescaped_quotes % 2 == 1) {
                            // odd number of unescaped quotes. In combination with the previous incomplete
                            // statement(s), we now have a complete statement. (2 odds always make an even)
                            $output[] = $temp . $tokens[$j];
                            // save memory.
                            $tokens[$j] = '';
                            $temp = '';
                            // exit the loop.
                            $complete_stmt = true;
                            // make sure the outer loop continues at the right point.
                            $i = $j;
                        } else {
                            // even number of unescaped quotes. We still dont have a complete statement.
                            // (1 odd and 1 even always make an odd)
                            $temp .= $tokens[$j] . $delimiter;
                            // save memory.
                            $tokens[$j] = '';
                        }
                    }
                }
            }
        }
        return $output;
    }
}
$u8c = new UTF8Converter();
$u8c->start();