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

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

TEST™

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

document.getElementById('test').innerHTML;

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 ™.

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

2

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.

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

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

EX

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

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

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

0
қосылды

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.

0
қосылды

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).

0
қосылды