繁体   English   中英

PHP 转换 ASCII 字符的问题 函数 chr()

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM