简体   繁体   English

如何将希腊语言的html实体转换为php中的实际符号

[英]How to convert html entities of greek language to actual symbols in php

I have greek site and all posts in it looks in sourse like: 我有一个希腊网站,并且所有帖子看起来都很像:

<p>&Omicron; &Mu;&pi;&#972;&nu;&omicron;&upsilon;&sigmaf; &Gamma;&#973;&rho;&omicron;&sigmaf; Drunken Clam &theta;&alpha; &delta;&epsilon;&#943;&tau;&epsilon; &theta;&alpha; &epsilon;&#943;&nu;&alpha;&iota; &sigma;&epsilon; &theta;&#941;&sigma;&eta; &nu;&alpha; &kappa;&epsilon;&rho;&delta;&#943;&zeta;&epsilon;&iota; &#972;&sigma;&omicron; 1000&Chi; &tau;&omicron;&upsilon; &sigma;&upsilon;&nu;&omicron;&lambda;&iota;&kappa;&omicron;&#973; &sigma;&tau;&omicron;&iota;&chi;&#942;&mu;&alpha;&tau;&omicron;&sigmaf; &epsilon;&pi;&iota;&lambda;&#941;&gamma;&omicron;&nu;&tau;&alpha;&sigmaf; &epsilon;&#943;&tau;&epsilon; Cleveland, Peter, Quagmire, &kappa;&alpha;&iota;</p>

Actually it looks like this on page like this: 实际上,它看起来像这样的页面:

Ο Μπόνους Γύρος Drunken Clam θα δείτε θα είναι σε θέση να κερδίζει όσο 1000Χ του συνολικού στοιχήματος επιλέγοντας είτε Cleveland, Peter, Quagmire, και ΟΜπόνους醉蛤lamθαδείτεθαείναισεθέσηνακερδίζειόσο1000Χτουσυνολικούστοτογίαπαιεπαπι

I need to change html entities to actual symbols (I'm using UTF-8 encoding.) Seems html_entity_decode() doesn't do this. 我需要将html实体更改为实际符号(我使用的是UTF-8编码。)似乎html_entity_decode()不能做到这一点。 Is here any library or somenthing like this for me to be able to convert text to actual symbols. 在这里,任何图书馆或类似的东西对我来说都可以将文本转换为实际符号。

PHP version PHP 5.3.29 PHP版本PHP 5.3.29

Thanks! 谢谢!

Upadate: Sorry, this was my shameful mistake. Upadate:对不起,这是我可耻的错误。 I messed mb_internal_encoding() and 'default_charset' ini directive while was debugging my issue. 在调试问题时,我弄乱了mb_internal_encoding()和'default_charset'ini指令。 So I was just have to set encoding for html_entity_decode work as third parameter: 所以我只需要将html_entity_decode工作的编码设置为第三个参数:

   $decoded = html_entity_decode($str, ENT_COMPAT | ENT_HTML401, "UTF-8");

just as Charlotte Dunois wrote. 正如夏洛特·杜诺瓦(Charlotte Dunois)所写。 So I set her answer as correct. 因此,我将她的答案设为正确。

If your data is html encoded (eg with PHP's function htmlentities ), you can use html_entity_decode to decode it back. 如果您的数据是html编码的(例如,使用PHP的htmlentities函数),则可以使用html_entity_decode进行解码。 You may need to set the charset argument if your set charset in the php.ini differs. 如果您在php.ini中设置的字符集不同,则可能需要设置字符集参数。

https://3v4l.org/Lmt38 https://3v4l.org/Lmt38

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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