私はまだどのように動作するのか理解していませんiconv
。
例えば、
$string = "Löic & René";
$output = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $string);
私は、
Notice: iconv() [function.iconv]: 入力文字列に無効な文字が検出されました...
$string = "Löic";
また$string = "René";
私は、
Notice:iconv() [function.iconv]:
入力文字列 in に不完全なマルチバイト文字が検出されました。
私は何も得ません$string = "&";
データベースのテーブル内の 2 つの異なる列に格納する必要がある 2 つの異なる出力のセットがあります。
きれいな URL の目的でに変換する必要があり
Löic & René
ます。Loic & Rene
それらをそのままにしておく必要があります-その後
Löic & René
、htmlページに表示するときにLöic & René
のみ変換します。htmlentities($string, ENT_QUOTES);
以下のphp.netの提案のいくつかを試してみましたが、それでもうまくいきません。
一部の文字を音訳する必要がある状況がありましたが、他の文字は無視されました (ayn や hamza などの奇妙な分音記号の場合)。//TRANSLIT//IGNORE を追加すると、うまくいったようです。音訳できるものはすべて音訳しますが、できないものは捨てます。
そう:
$string = "ʿABBĀSĀBĀD";
echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $string);
// output: [nothing, and you get a notice]
echo iconv('UTF-8', 'ISO-8859-1//IGNORE', $string);
// output: ABBSBD
echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $string);
// output: ABBASABAD
// Yay! That's what I wanted!
そしてもう一つ、
Andries Seutens 07-Nov-2009 07:38
When doing transliteration, you have to make sure that your LC_COLLATE is properly set, otherwise the default POSIX will be used.
To transform "rené" into "rene" we could use the following code snippet:
setlocale(LC_CTYPE, 'nl_BE.utf8');
$string = 'rené';
$string = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
echo $string; // outputs rene
どうすればそれらを実際に解決できますか?
ありがとう。
編集:
これは、コードをテストするソース ファイルです。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="no-js">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<?php
$string = "Löic & René";
$output = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $string);
?>
</html>