note 52656 added to function.utf8-decode

From: Date: Sun, 08 May 2005 22:41:33 +0000
Subject: note 52656 added to function.utf8-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-89132@lists.php.net to get a copy of this message
If you want to convert utf-8 to ascii, you can use the following procedure: <?php function utf2ascii($string) { $string=iconv('utf-8','windows-1250',$string); $win ='žýáíéú...'; // I was unable to paste here all set of characters, but you get the point $ascii='zyaieuu...'; $string = StrTr($string,$win,$ascii); return $string; } ?> This works based on the assumption that you know what language text (and thus what charset) you want to convert from. In the above example I am converting from an eastern European language, so I know I can safely use windows-1250 charset as an intermediem charset. You will have to adjust the charset based on your language. Please remember that you have to save this file separately and it must be coded in the charset, which you will call within function iconv. Otherwise it will not work. ---- Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52656 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52656&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52656&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52656&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52656&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52656&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52656&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89132) next »