mysql with arabic text

Ahmed

mysql with arabic text

Post by Ahmed »

Arabic text could be used with mysql 4.1.* and up, first the database and
each table field should have utf8 encoding.

ALTER DATABASE `database_name` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin

To create new tables with utf8 encoding use:

CREATE TABLE `test` (
`a` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ,
) ENGINE = MYISAM ;

To alter existing tables use:

ALTER TABLE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin

If you are using Perl to retrieve Arabic text then you should issue the
following sql statement:
$dbh->do("SET CHARACTER SET 'cp1256'");

Instead of using print header(),use:
print "Content-type: text/html; charset=windows-1256\n\n";

cp1256 is for Arabic language other languages have different encoding.