iso dan utf-8 e geçiş…
Nis.24, 2009, PHP
İhtiyacımız olabilir bazen oluyor…
$ourTree = rscandir();
$onlyFiles = array();
foreach ($ourTree as $file) {
if (!is_dir($file)) {
if (!preg_match(‘%/\.svn%’, $file)) {
$mimecontenttype = mime_content_type($file);
if ($mimecontenttype == ‘text/plain’) {
$encoding = mb_detect_encoding(file_get_contents($file), ‘UTF-8, ISO-8859-9, ISO-8859-1′);
$result = mb_convert_encoding( $file, ‘UTF-8′, ‘ISO-8859-9′);
$iconv = file_put_contents($file, iconv(“ISO-8859-9″, “UTF-8″, file_get_contents($file)));
$onlyFiles[] = array(
‘file’ => $file,
‘currentEncoding’ => $encoding,
‘result’ => $result,
‘mime’ => $mimecontenttype,
‘iconv’ => $iconv,
‘test’ => mb_detect_encoding(file_get_contents($file), ‘UTF-8, ISO-8859-9, ISO-8859-1′)
);
}
}
}
}
print_r($onlyFiles);
Nisan 24th, 2009 13:44
[...] See original here: iso dan utf-8 e geçiş… [...]
Eylül 1st, 2009 15:43
Keşke bu yazıyı daha önce görseydim.
Başıma bir sürü işler açmadan:)
Eylül 3rd, 2009 11:52
#!/bin/sh
for file in *.txt; do
iconv -f WINDOWS-1251 -t UTF-8 $file> tmp.txt;
mv tmp.txt $file
echo $file
done
da işini görecektir. Bu arada fark ettim ki siteme özen göstermeliyim