|
|
|
| Проблема такого рода:
Естьт дамп базы данных
CREATE DATABASE `db` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
CREATE TABLE `table` (
`aid` int(11) NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
PRIMARY KEY (`aid`)
) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;
INSERT INTO `table` VALUES (1, 'Îòêðûòèå ãîðГëûæГîãî êóðîðòà â Г±.Èâà 2006ГЈ');
......
|
Вместо данных в sql- нечитаемая кодировка.
Дамп на прошлом хостинге работал корректно в скриптах, в пхпмй админ виден в таком же виде
Как импортировать данный дамп в базу cp1251 ???
Очень надо | |
|
|
|
|
|
|
|
для: stasmus
(16.06.2007 в 18:55)
| | Двойное нарушение кодировок.
<?
$dmp = <<<ENDCODE
CREATE DATABASE `db` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
CREATE TABLE `table` (
`aid` int(11) NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
PRIMARY KEY (`aid`)
) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;
INSERT INTO `table` VALUES (1, 'Г_Г_ГЄГ°Г>Г_ГЁГ_ Г_ГRГ°Г-Г<Г>Г│Г-ГRГ_ГR ГЄГ_Г°ГRГ°Г_ Гў Г+.Г_Гў 2006Г_');
......
ENDCODE;
$dmp = iconv('UTF-8', 'ISO-8859-1', $dmp);
header("Content-Type: text/plain; charset=windows-1251");
echo $dmp;
?>
|
>Дамп на прошлом хостинге работал корректно в скриптах, в пхпмй админ виден в таком же виде
Не мог он работать нормально.
Мог работать только и исключительно через жопу.
Не могла база, обозванная latin1 хранить русский текст. Нет в latin1 русских букв. Только латинские. | |
|
|
|
|
|
|
|
для: Trianon
(16.06.2007 в 21:26)
| | Не поверишь, но как то мог...
Решение проблемы:
$file='snow.sql';
$data='';
$fp=fopen($file,"rb");
if (!$fp)
die('Cant open source file');
$fp_out=fopen($file.".convert","wb");
if (!$fp_out)
die('Cant open file');
$start=getmicrotime();
$chars=array(
chr(hexdec("c3")).chr(hexdec("a0")),
chr(hexdec("c3")).chr(hexdec("a1")),
chr(hexdec("c3")).chr(hexdec("a2")),
chr(hexdec("c3")).chr(hexdec("a3")),
chr(hexdec("c3")).chr(hexdec("a4")),
chr(hexdec("c3")).chr(hexdec("a5")),
chr(hexdec("c2")).chr(hexdec("b8")),
chr(hexdec("c3")).chr(hexdec("a6")),
chr(hexdec("c3")).chr(hexdec("a7")),
chr(hexdec("c3")).chr(hexdec("a8")),
chr(hexdec("c3")).chr(hexdec("a9")),
chr(hexdec("c3")).chr(hexdec("aa")),
chr(hexdec("c3")).chr(hexdec("ab")),
chr(hexdec("c3")).chr(hexdec("ac")),
chr(hexdec("c3")).chr(hexdec("ad")),
chr(hexdec("c3")).chr(hexdec("ae")),
chr(hexdec("c3")).chr(hexdec("af")),
chr(hexdec("c3")).chr(hexdec("b0")),
chr(hexdec("c3")).chr(hexdec("b1")),
chr(hexdec("c3")).chr(hexdec("b2")),
chr(hexdec("c3")).chr(hexdec("b3")),
chr(hexdec("c3")).chr(hexdec("b4")),
chr(hexdec("c3")).chr(hexdec("b5")),
chr(hexdec("c3")).chr(hexdec("b6")),
chr(hexdec("c3")).chr(hexdec("b7")),
chr(hexdec("c3")).chr(hexdec("b8")),
chr(hexdec("c3")).chr(hexdec("b9")),
chr(hexdec("c3")).chr(hexdec("ba")),
chr(hexdec("c3")).chr(hexdec("bb")),
chr(hexdec("c3")).chr(hexdec("bc")),
chr(hexdec("c3")).chr(hexdec("bd")),
chr(hexdec("c3")).chr(hexdec("be")),
chr(hexdec("c3")).chr(hexdec("bf")),
chr(hexdec("c3")).chr(hexdec("80")),
chr(hexdec("c3")).chr(hexdec("81")),
chr(hexdec("c3")).chr(hexdec("82")),
chr(hexdec("c3")).chr(hexdec("83")),
chr(hexdec("c3")).chr(hexdec("84")),
chr(hexdec("c3")).chr(hexdec("85")),
chr(hexdec("c2")).chr(hexdec("a8")),
chr(hexdec("c3")).chr(hexdec("86")),
chr(hexdec("c3")).chr(hexdec("87")),
chr(hexdec("c3")).chr(hexdec("88")),
chr(hexdec("c3")).chr(hexdec("89")),
chr(hexdec("c3")).chr(hexdec("8a")),
chr(hexdec("c3")).chr(hexdec("8b")),
chr(hexdec("c3")).chr(hexdec("8c")),
chr(hexdec("c3")).chr(hexdec("8d")),
chr(hexdec("c3")).chr(hexdec("8e")),
chr(hexdec("c3")).chr(hexdec("8f")),
chr(hexdec("c3")).chr(hexdec("90")),
chr(hexdec("c3")).chr(hexdec("91")),
chr(hexdec("c3")).chr(hexdec("92")),
chr(hexdec("c3")).chr(hexdec("93")),
chr(hexdec("c3")).chr(hexdec("94")),
chr(hexdec("c3")).chr(hexdec("95")),
chr(hexdec("c3")).chr(hexdec("96")),
chr(hexdec("c3")).chr(hexdec("97")),
chr(hexdec("c3")).chr(hexdec("98")),
chr(hexdec("c3")).chr(hexdec("99")),
chr(hexdec("c3")).chr(hexdec("9a")),
chr(hexdec("c3")).chr(hexdec("9b")),
chr(hexdec("c3")).chr(hexdec("9c")),
chr(hexdec("c3")).chr(hexdec("9d")),
chr(hexdec("c3")).chr(hexdec("9e")),
chr(hexdec("c3")).chr(hexdec("9f"))
);
$letters=array(
'а','б','в','г','д','е','ё','ж','з','и',
'й','к','л','м','н','о','п','р','с','т',
'у','ф','х','ц','ч','ш','щ','ъ','ы','ь',
'э','ю','я',
'А','Б','В','Г','Д','Е','Ё','Ж','З','И',
'Й','К','Л','М','Н','О','П','Р','С','Т',
'У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь',
'Э','Ю','Я'
);
$datasize=0;
while (!feof($fp))
{
$data=fread($fp,1024);
$one=ord($data.=fread($fp,1));
if (($one ==hexdec("c2"))||($one ==hexdec("c3")) )
$one=ord($data.=fread($fp,1));
$datasize+=strlen($data);
if (!fwrite($fp_out,str_replace($chars,$letters,$data)))
echo "Bad copy<br>";
}
$endread=getmicrotime();
echo "Full Time: ".($endread-$start)."<br>";
echo "Data size: ".($datasize/1024/1024)." MB <br>";
function getmicrotime()
{
$time=split(" ",microtime());
return $time[0]+$time[1];
}
|
Full Time: 6.7216489315
Data size: 20.4974975586 MB | |
|
|
|
|
|
|
|
для: stasmus
(17.06.2007 в 10:09)
| | iconv-ом было не воспользоваться? | |
|
|
|
|