[英]PHP Problems translating ASCII characters Function chr()
我在用 ascii 表翻譯字符時遇到問題。 像“或”“或”這樣的罕見引號示例
部分代碼
$txt = str_replace(chr(147), '"', $txt ); // left double quote
有人可以知道什么是到期,似乎找不到字符串中的字符
這可能會幫助您解決任何問題:
<?php
/* to avoid diamond shaped / garbled character output in browser
make the browser uses the correct encoding. Use a header.
*/
header("Content-Type: text/html; charset=ISO-8859-1");
$chr = chr(147);
echo 'replacing ' . $chr . ' in target string.' . '<br />';
$txt = 'sometext' . $chr . 'andthensomemore' . $chr . 'andterminate';
echo 'BEFORE : ' . $txt . '<br />';
$txt = str_replace($chr, '"', $txt );
echo 'AFTER : ' . $txt;
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.