Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting webpages from UTF-8 to ISO-8859-1 in linux

Anyone have a neat trick on how to convert a number of php and html files from UTF-8 to ISO-8859-1 in linux (Ubuntu)?

like image 466
Svish Avatar asked Mar 27 '09 18:03

Svish


People also ask

How do I convert UTF-8 to ISO 8859-1?

byte[] utf8 = ... byte[] latin1 = new String(utf8, "UTF-8"). getBytes("ISO-8859-1"); You can exercise more control by using the lower-level Charset APIs. For example, you can raise an exception when an un-encodable character is found, or use a different character for replacement text.

What is the difference between ISO 8859-1 and UTF-8?

UTF-8 is a multibyte encoding that can represent any Unicode character. ISO 8859-1 is a single-byte encoding that can represent the first 256 Unicode characters. Both encode ASCII exactly the same way.


1 Answers

Ubuntu has recode

$ sudo apt-get install recode
$ recode UTF-8..latin1 *.php

Recursively, thanks to Ted Dziuba:

$ find . -name "*.php" -exec recode UTF-8..latin1 {} \;
like image 84
HMM Avatar answered Nov 05 '22 23:11

HMM