Displaying degree symbol on webpage

喜夏-厌秋 提交于 2021-02-05 04:46:26

问题


I have a program which extracts GPS coordinates from metadata and imports the results onto a database. I then display the data using PHP on a webpage.

My problem - I've recently created a new template but for whatever reason, it is no longer showing the degrees symbol '°' but a '�'.

I just find it strange that it works with one template, but not the other?

I've tried changing fonts, but had no luck


回答1:


See DEGREE CHARACTER.

Specifically, HTML Entity: °.

Check that you have the proper docstring and character encoding in both templates to make sure they are correct.




回答2:


You can use:

utf8_encode('YOUR TEXT');

utf8_encode converts the string data from the ISO-8859-1 encoding to UTF-8.




回答3:


  1. Save your PHP file with UTF-8 encoding.
  2. Serve your PHP file with charset=UTF-8.
  3. Add a META-tag in your HTML with charset=UTF-8.

This will solve (almost) all of your unicode character problems.




回答4:


When you input or pull the data from you database, use htmlentities()

you can find a good guide on this function a here http://php.net/manual/en/function.htmlentities.php




回答5:


For degree celcius in html

<span>&#8451;</span>


来源:https://stackoverflow.com/questions/14468477/displaying-degree-symbol-on-webpage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!