Failų konvertavimas į unicode utf8

Iš Žinynas.
Jump to navigation Jump to search

Kurie failai ne utf8 ready?

find . -type f -exec file --mime {} \; | grep -v "charset=utf-8"
find . -type f | xargs -I {} bash -c "iconv -f utf-8 -t utf-16 {} &>/dev/null || echo {}" > utf8_fail

PHP failų konvertavimas į UTF-8 unicode:

find . -type f -iname "*.php" -exec sh -c 'iconv -f $(file -bi "$1" |sed -e "s/.*[ ]charset=//") -t utf-8 -o converted "$1" && mv converted "$1"' -- {} \;

OSX Variantas:

find . -type f -iname "*.php" -exec sh -c 'iconv -f $(file -b --mime-encoding "$1" | awk "{print toupper(\$0)}") -t UTF-8 > converted "$1" && mv converted "$1"' -- {} \;