cvs: peardoc /phd-db5-conversion pear_conversion.php
| From: | Christian Weiske | Date: | Mon, 06 Oct 2008 18:38:10 +0000 |
| Subject: | cvs: peardoc /phd-db5-conversion pear_conversion.php | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-11138@lists.php.net to get a copy of this message | ||
cweiske Mon Oct 6 18:38:10 2008 UTC
Modified files:
/peardoc/phd-db5-conversion pear_conversion.php
Log:
Convert cdata encodings
http://cvs.php.net/viewvc.cgi/peardoc/phd-db5-conversion/pear_conversion.php?r1=1.2&r2=1.3&diff_format=u
Index: peardoc/phd-db5-conversion/pear_conversion.php
diff -u peardoc/phd-db5-conversion/pear_conversion.php:1.2
peardoc/phd-db5-conversion/pear_conversion.php:1.3
--- peardoc/phd-db5-conversion/pear_conversion.php:1.2 Sun Oct 5 15:17:47 2008
+++ peardoc/phd-db5-conversion/pear_conversion.php Mon Oct 6 18:38:10 2008
@@ -73,6 +73,13 @@
function cloakCDATA($file)
{
$contents = file_get_contents($file);
+ //detect encoding
+ $header = substr($contents, 0, 50);
+ if (preg_match('/encoding=[\'"]([^\'"]+)[\'"]/',
$header, $arMatches)) {
+ $encoding = strtolower($arMatches[1]);
+ } else {
+ $encoding = 'utf-8';
+ }
//db5 currently does not allow <constant> in <initializer>
foreach (array('null', 'true', 'false') as $type) {
@@ -97,7 +104,16 @@
$cdata = array();
$counter = -1;
while (preg_match("/<!\[CDATA\[(.*?)\]\]>/si", $contents, $matches)) {
- $cdata[] = $matches[0];
+ if ($encoding != 'utf-8') {
+ //if ($bMb) {
+ $dat = mb_convert_encoding($matches[0], 'utf-8', $encoding);
+ //} else {
+ //$dat = iconv($encoding, 'utf-8', $matches[0]);
+ //}
+ } else {
+ $dat = $matches[0];
+ }
+ $cdata[] = $dat;
$contents = str_replace($matches[0], 'whereyouseedatanow' . ++$counter .
'youdontseedata', $contents);
}
if (count($cdata)) {