简体   繁体   English

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

[英]PHP Problems translating ASCII characters Function chr()

I have a problem translating characters with the ascii table.我在用 ascii 表翻译字符时遇到问题。 Example rare quotes like “ or ” 'or'像“或”“或”这样的罕见引号示例

Part of the code部分代码

$txt = str_replace(chr(147), '"', $txt );    // left double quote

Someone can know what is due, it seems that you can not find the characters in the string有人可以知道什么是到期,似乎找不到字符串中的字符

This might help you solve any issues:这可能会帮助您解决任何问题:

<?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