«DOMDocument XPath» файлына айналдырылады

Егерде бар болса


және мен қолданамын


PHP функциясына HTML жіберіп, онда DOMDocument және XPath арқылы барлық мәтін түйіндерін шығарады.

When the PHP gets the content the gets converted to ™. I run it through XPath and the text node comes back as:

TESTâ„ ¢

I am not sure what is going wrong, or if there is a way fix it, either on the JavaScript side so it passes the rather then ™.

Кез келген көмекті бағалайды.


4 жауаптар

Your value that your variable is being passed with the TM character, not with , running through htmlentities() in PHP should take care of it.

Бұл жұмыс істемейді, ол тек қана қайтарады
қосылды автор eagle12, көзі

HTML Unicode пішінін қолданып көріңіз


Unicode TM туралы қосымша мысал үшін осы бетті оқыңыз

http://www.fileformat.info/info/unicode/char/2122 /index.htm

Бұл көмектеседі деп үміттенемін.


You need to be more precise than saying it "comes back as". The ™ appears to have been written somewhere in UTF-8 encoding, and the same bytes have then been read by something that doesn't realise they are in UTF-8 encoding, and is assuming they are Latin-1 or similar. To solve the problem you will need to look very carefully at the configuration of the software that wrote the character and the software that read it.


What Michael said is true; in addition you should be aware that xml processors are basically required to convert character entities (like &tm;) to their actual character values, and will (almost) always produce output with those characters encoded in some prevailing character set. It takes heroic measures to prevent this, and is usually not a "good idea". So you should abandon attempts to do that, and my guess is that you would be better served by making sure that the function you are passing the HTML to is told to interpret it as utf-8 not some other charset (which may just be the system default).