Difference between revisions of "UTF-8 Compatible"

From CSWiki
Jump to navigation Jump to search
Line 1: Line 1:
 
=== Converting WebPages to UFT-8 ===
 
=== Converting WebPages to UFT-8 ===
grconv -T UTF -t is0-8859-7
+
grconv -T UTF -t iso-8859-7 ''iso_filename'' > ''utf_filename''
 +
Alternatively you can use the iconv command which is available on most systems
 +
iconv -f iso-8859-7 -t utf-8 ''iso_filename'' > ''utf_filename''
 +
 
 +
The next three-line script  will search for all your html and php files and convert them to utf-8 <br>
 +
{{red| '''!!! WARNING !!!:''' The following script is provided as is. '''USE AT YOUR OWN RISK!!!''' <br> I am not responsible for data or life loss by using it.}} [[User:Savvasn|nsc]]
 +
find . \( -name "*.htm*" -o -name "*.php" \) -exec sed -i.iso 's/charset\=iso\-8859\-7/utf\-8/g' '{}' \;
 +
for i in `find . \( -name "*.htm*" -o -name "*.php" \)` ; do iconv -f iso-8859-7 -t utf-8 $i.iso > $i; done
 +
find . \( -name "*.htm*" -o -name "*.php" \) -exec sed -i 's/charset\=iso\-8859\-7/utf\-8/g' '{}' \;
 +
 
 +
{{red| '''NOTE:''' The above lines are only an example of how you can convert your site to be utf compatible. The second line is only working if you are in bash shell}}
 +
 
 
=== Converting MySQL databases to UTF-8 ===
 
=== Converting MySQL databases to UTF-8 ===
 
Dump the db in an SQL file.  
 
Dump the db in an SQL file.  

Revision as of 11:40, 8 February 2007

Converting WebPages to UFT-8

grconv -T UTF -t iso-8859-7 iso_filename > utf_filename Alternatively you can use the iconv command which is available on most systems iconv -f iso-8859-7 -t utf-8 iso_filename > utf_filename

The next three-line script will search for all your html and php files and convert them to utf-8
!!! WARNING !!!: The following script is provided as is. USE AT YOUR OWN RISK!!!
I am not responsible for data or life loss by using it.
nsc

find . \( -name "*.htm*" -o -name "*.php" \) -exec sed -i.iso 's/charset\=iso\-8859\-7/utf\-8/g' '{}' \;
for i in `find . \( -name "*.htm*" -o -name "*.php" \)` ; do iconv -f iso-8859-7 -t utf-8 $i.iso > $i; done
find . \( -name "*.htm*" -o -name "*.php" \) -exec sed -i 's/charset\=iso\-8859\-7/utf\-8/g' '{}' \;

NOTE: The above lines are only an example of how you can convert your site to be utf compatible. The second line is only working if you are in bash shell

Converting MySQL databases to UTF-8

Dump the db in an SQL file.

mysqldump -u root -p --lock-tables --default-character-set=greek dbname > dbname.sql

Edit the SQL file and insert the following two lines at the beginning of it.

CREATE DATABASE <dbname> DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE <dbname>;

Telling MySQL to query in UTF-8 mode

Letting PHP know that you are working with UTF-8

Edit /etc/php.ini and insert the following line
default_charset = "utf-8"