Anti HostMonster

Commands using iconv to fix website Characters

by admin on Jun.03, 2009, under Best Webhosts

Here are some useful SSH commands to fix special characters on your website.
Sometimes you would see ? or strange charsets…
Recommended to use UTF-8 and have your database collation also as utf-8
Convert a bunch of HTML files from ISO-8859-1 to UTF-8 file encoding in a folder and all sub-folders
for x in `find . -name ‘*.html’` ; do iconv -f ISO-8859-1 -t UTF-8 $x > “$x.utf8″; rm $x; mv “$x.utf8″ $x; done
Convert mysql database from latin1 to utf8
mysqldump –add-drop-table -uroot -p “DB_name” | replace CHARSET=latin1 CHARSET=utf8 | iconv -f latin1 -t utf8 | mysql -uroot -p “DB_name”
find . -name “*.php” -exec iconv -f ISO-8859-1 -t UTF-8 {} -o ../newdir_utf8/{} \;
Batch convert files to utf-8
iconv -f ISO8859-1 -t UTF-8 OLDFILE > NEWFILE

For example in ssh type:
iconv -f ISO8859-1 -t UTF-8 listing_default.tpl >listing_default2.tpl

Then rename or delete your old listing_default.tpl and rename listing_default2.tpl to listing_default.tpl

Leave a Reply

Anti-Spam Protection by WP-SpamFree

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Archives

All entries, chronologically...