note 43463 added to function.iconv

From: Date: Tue, 22 Jun 2004 12:11:00 +0000
Subject: note 43463 added to function.iconv
Groups: php.notes 
Request: Send a blank email to php-notes+get-71491@lists.php.net to get a copy of this message
Here is a code to convert ISO 8859-1 to UTF-8 and vice versa without using iconv. <?php //Logic from http://twiki.org/cgi-bin/view/Codev/InternationalisationUTF8 $str_iso8859_1 = 'foo in ISO 8859-1'; //ISO 8859-1 to UTF-8 $str_utf8 = preg_replace("/([\x80-\xFF])/e", "chr(0xC0|ord('\\1')>>6).chr(0x80|ord('\\1')&0x3F)", $str_iso8859_1); //UTF-8 to ISO 8859-1 $str_iso8859_1 = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e", "chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)", $str_utf8); ?> HTH, R. Rajesh Jeba Anbiah ---- Manual Page -- http://www.php.net/manual/en/function.iconv.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43463 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43463&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43463&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#71491) next »