What is the correct syntax in php for echo UTF-8?

Possible duplicate:
How do you print raw UTF-8 characters from their numbers? [Php]

This code works: echo ' & # 3 4 ; ' echo ' & # 3 4 ; ' print a double quote on my web page.

This, on the other hand, is clearly wrong: echo ' U + 2 5 B 2 ' just prints literal characters.

What is the correct syntax? By the way, U+25B2 should be an upward pointing triangle. I would like to use it to select html with its triangle down.

+4
source share
3 answers

Do the same as with your quote:

 echo '▲'; 

You can find information about the HTML object on FileFormat.Info .

+1
source

Add the header below on the PHP page. I think he should take care of printing the desired character.

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

and repeat your value with a UTF char like:

 echo "\xE2\x96\xB2"; 

Note : E2 96 B2 equivalent of UTF-8 to U+25B2 UTF-16 for your upward triangle.

0
source

u+25b2 is just a well-formed human string representing two bytes of a certain sequence of Unicode characters. In essence, the string form means nothing to the browser, because it is a human version. To see the actual character represented by this code sequence, you must output raw bytes, for example. 0x25 and 0xb2.

0
source

Source: https://habr.com/ru/post/1443906/


All Articles