note 52656 deleted from function.utf8-decode by cmb
| From: | cmb@php.net | Date: | Sun, 11 Dec 2016 11:38:03 +0000 |
| Subject: | note 52656 deleted from function.utf8-decode by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208542@lists.php.net to get a copy of this message | ||
Note Submitter: Vladimir Stwora, vlad4321 at fastmail dot fm
----
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.