为什么有的页面乱码,为什么有的乱码不乱码?有点晕
请看这两个页面:http://www.qgren.com/qigong/gongfa/15_30.shtml
摘要出现乱码。
再看这个页面:http://www.qgren.com/qigong/gongfa/15_28.shtml
摘要没有乱码,很正常。
在网站,部分页面正常,部分页面摘要乱码。我有点晕。
程序是dedecms,gbk版本。我网页模板也是gbk。
调用摘要的代码如下:
{dede:field.description runphp='yes'}
if(@me'' )@me = '
摘要:'.@me.'
';{/dede:field.description}
不知道谁能解我疑惑,为什么会这样?
回复讨论(解决方案)
无余没、无余欲 後有特殊字符。
?查一下。
被加入了空格,删掉即可
观察到 meta 中是一样的乱码,所以就从 meta 中取了
$t = get_meta_tags('http://www.qgren.com/qigong/gongfa/15_30.shtml');echo '乱码:', $s = $t['description'], PHP_EOL;echo '还原:', str_replace(' ', '', $s);
还原:阿难。有犯戒。彼于心解脱、慧解脱如实知。彼于所起犯戒无余灭、无余没、无余欲荆当知是人胜进不退。我说彼人为胜进分。自非如来。此二有间。谁能悉知。是故。阿难。莫筹量人人而龋人善筹量人人而玻人筹量人人
虽然看到的是所谓的空格,但也可能是某个汉字的变异
所以请核对文字后告知差异
被加入了空格,删掉即可
观察到 meta 中是一样的乱码,所以就从 meta 中取了
$t = get_meta_tags('http://www.qgren.com/qigong/gongfa/15_30.shtml');echo '乱码:', $s = $t['description'], PHP_EOL;echo '还原:', str_replace(' ', '', $s);
还原:阿难。有犯戒。彼于心解脱、慧解脱如实知。彼于所起犯戒无余灭、无余没、无余欲荆当知是人胜进不退。我说彼人为胜进分。自非如来。此二有间。谁能悉知。是故。阿难。莫筹量人人而龋人善筹量人人而玻人筹量人人
文字差异:
还原:阿难。有犯戒。彼于心解脱、慧解脱如实知。彼于所起犯戒无余灭、无余没、无余欲荆当知是人胜进不退。我说彼人为胜进分。自非如来。此二有间。谁能悉知。是故。阿难。莫筹量人人而龋人善筹量人人而玻人筹量人人
文字:阿难。有犯戒。彼于心解脱、慧解脱如实知。彼于所起犯戒无余灭、无余没、无余欲 尽。当知是人胜进不退。我说彼人为胜进分。自非如来。此二有间。谁能悉知。是故。阿难。莫筹量人人而 取。人善筹量人人而病。人筹量人人
找到共同规律,都是一个字后接一个句号。
版主看看
无余没、无余欲 後有特殊字符。
?查一下。
无余没、无余欲 后面并没有特殊字符,见文档。后面是 尽。
无余灭、无余没、无余欲尽。当知是人胜进不退。
$t = get_meta_tags('http://www.qgren.com/qigong/gongfa/15_30.shtml');$s = $t['description'];$n = strpos($s, '欲')+2;$t = substr($s, $n);echo bin2hex('尽。当'), PHP_EOL;echo bin2hex($t), PHP_EOL;$n = strpos($s, '而')+2;$t = substr($s, $n);echo bin2hex('取。人'), PHP_EOL;echo bin2hex($t), PHP_EOL;echo str_replace(' ', "\xa1\xa1", $s), PHP_EOL;echo bin2hex(' '); //再看看全角空格
bea1a1a3b5b1be20a3b5b1d6aacac7c8cbcaa4bdf8b2bbcdcba1a3ced2cbb5b1cbc8cbceaacaa4bdf8b7d6a1a3d7d4b7c7c8e7c0b4a1a3b4cbb6fed3d0bce4a1a3cbadc4dccfa4d6aaa1a3cac7b9caa1a3b0a2c4d1a1a3c4aab3efc1bfc8cbc8cbb6f8c820a3c8cbc9c6b3efc1bfc8cbc8cbb6f8b220a3c8cbb3efc1bfc8cbc8cba1c8a1a1a3c8cbc820a3c8cbc9c6b3efc1bfc8cbc8cbb6f8b220a3c8cbb3efc1bfc8cbc8cba1阿难。有犯戒。彼于心解脱、慧解脱如实知。彼于所起犯戒无余灭、无余没、无余欲尽。当知是人胜进不退。我说彼人为胜进分。自非如来。此二有间。谁能悉知。是故。阿难。莫筹量人人而取。人善筹量人人而病。人筹量人人?a1a1
很显然,你在处理文字时做了将全角空格替换成半角空格的处理
这就是问题的根源!
$t = get_meta_tags('http://www.qgren.com/qigong/gongfa/15_30.shtml');$s = $t['description'];$n = strpos($s, '欲')+2;$t = substr($s, $n);echo bin2hex('尽。当'), PHP_EOL;echo bin2hex($t), PHP_EOL;$n = strpos($s, '而')+2;$t = substr($s, $n);echo bin2hex('取。人'), PHP_EOL;echo bin2hex($t), PHP_EOL;echo str_replace(' ', "\xa1\xa1", $s), PHP_EOL;echo bin2hex(' '); //再看看全角空格
bea1a1a3b5b1be20a3b5b1d6aacac7c8cbcaa4bdf8b2bbcdcba1a3ced2cbb5b1cbc8cbceaacaa4bdf8b7d6a1a3d7d4b7c7c8e7c0b4a1a3b4cbb6fed3d0bce4a1a3cbadc4dccfa4d6aaa1a3cac7b9caa1a3b0a2c4d1a1a3c4aab3efc1bfc8cbc8cbb6f8c820a3c8cbc9c6b3efc1bfc8cbc8cbb6f8b220a3c8cbb3efc1bfc8cbc8cba1c8a1a1a3c8cbc820a3c8cbc9c6b3efc1bfc8cbc8cbb6f8b220a3c8cbb3efc1bfc8cbc8cba1阿难。有犯戒。彼于心解脱、慧解脱如实知。彼于所起犯戒无余灭、无余没、无余欲尽。当知是人胜进不退。我说彼人为胜进分。自非如来。此二有间。谁能悉知。是故。阿难。莫筹量人人而取。人善筹量人人而病。人筹量人人?a1a1
很显然,你在处理文字时做了将全角空格替换成半角空格的处理
这就是问题的根源!
还是有点乱码,人筹量人人 ?。多了一个怪异的东东。
我把你这段代码试过了,有点纳闷,纳闷的是
echo str_replace(' ', "\xa1\xa1", $s);
这段代码后面不输出东西, ?,这个怪异的东东就不会出现。
反之,只要后面输出什么,比如你的代码,输出个PHP_EOL, ?就出现了。
真的好奇怪啊

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
