Why Not ?

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);

3 yorum:
  1. iso dan utf-8 e geçiş… | Webmaster Tools

    [...] See original here:  iso dan utf-8 e geçiş… [...]

  2. Gözde

    Keşke bu yazıyı daha önce görseydim.
    Başıma bir sürü işler açmadan:)

  3. Murat Beşer

    :) Linux veya Mac üzerinde shell yetkin varsa

    #!/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 :D

Yorumla

Bir şeylere mi baktın ?

O zaman arama motorunu kullan:

hala mı bulamadın, o zaman bir mail atı ver. ilgilenirim.!

Bazı arkadaşlarım!

Takip etmenizde fayda var...