note 94799 added to function.utf8-decode

From: Date: Wed, 25 Nov 2009 16:13:05 +0000
Subject: note 94799 added to function.utf8-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-163269@lists.php.net to get a copy of this message
a simple function to convert encoding that appears mixed. $trans = new Latin1UTF8(); $mixed = "MIXED TEXT INPUT"; print "Original: ".$mixed; print "Latin1: ".$trans->mixed_to_latin1($mixed); print "UTF-8: ".$trans->mixed_to_utf8($mixed); class Latin1UTF8 { private $latin1_to_utf8; private $utf8_to_latin1; public function __construct() { for($i=32; $i<=255; $i++) { $this->latin1_to_utf8[chr($i)] = utf8_encode(chr($i)); $this->utf8_to_latin1[utf8_encode(chr($i))] = chr($i); } } public function mixed_to_latin1($text) { foreach( $this->utf8_to_latin1 as $key => $val ) { $text = str_replace($key, $val, $text); } return $text; } public function mixed_to_utf8($text) { return utf8_encode($this->mixed_to_latin1($text)); } } ---- Server IP: 87.124.86.47 Probable Submitter: 86.173.109.245 (proxied: 86.173.109.245) ---- Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php Edit -- https://master.php.net/note/edit/94799 Del: integrated -- https://master.php.net/note/delete/94799/integrated Del: useless -- https://master.php.net/note/delete/94799/useless Del: bad code -- https://master.php.net/note/delete/94799/bad+code Del: spam -- https://master.php.net/note/delete/94799/spam Del: non-english -- https://master.php.net/note/delete/94799/non-english Del: in docs -- https://master.php.net/note/delete/94799/in+docs Del: other reasons-- https://master.php.net/note/delete/94799 Reject -- https://master.php.net/note/reject/94799 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163269) next »