Fixing badly encoded utf-8 files

From Urandom
Jump to navigation Jump to search

Sometimes i stumble on files that are supposed to be UTF-8 but they contain characters that are not recognized by kde-4 KATE text editor, sometimes even preventing any edits in the file or causing the "all craracters could not be encoded" and warns that you might lose data.

To fix the file i save the file to iso-8859-15 format(could be anything other too)

iconv -f iso-8859-15 -t utf-8 file.php > file-uni.php

Another day saved!