not being displayed properly

前端 未结 5 1973
无人及你
无人及你 2021-01-07 01:35

I am having problem in displaying the   in my web page, after using utf8_decode() in PHP it gets displayed as �.

i have been using



        
相关标签:
5条回答
  • 2021-01-07 01:44

    When you use utf8_decode, the string that is passed to this function where is it loaded from? Are you loading data from database? Do you have any included files? If so, check that they are all encoded as GmonC wrote. Try to echo   somewhere in page and see if it will show correctly. If not, try to make clean .php file and than see if problem still occurs. If not than some included file could be the problem because it could have different encoding

    0 讨论(0)
  • 2021-01-07 01:48

    Also make sure you give the document a proper dtd definition by putting something like this:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    

    As the first line of html in your php file.

    0 讨论(0)
  • 2021-01-07 01:49

    Be sure that you've specified UTF-8 encoding in your HTML document's tag:

      <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
    
    0 讨论(0)
  • 2021-01-07 02:06

    That's strange since utf8_encode('&nbsp;')==='&nbsp;'. Regardless of whether it's utf8 or latin1 encoded the byte-sequence for &nbsp; is the same.
    Is the remaining string properly utf8 encoded?

    edit: Why do you use utf8_decode() (converting utf8 encoded strings to latin1) in the first place when you're telling the browser that your page is utf8 encoded?

    0 讨论(0)
  • 2021-01-07 02:06

    Have you checked the encoding of the php file itself?

    In some windows editors (like notepad++) you can have some utf-8 character problems when you check the wrong encoding for your file - even if you set your meta tag correctly.

    In notepad++ you can change it in this section:

    Change notepad++ file encoding http://img198.imageshack.us/img198/9081/notepadp.png

    If you're not using notepad++, we'll need some more detailed information from your setup, like Operating System used, IDE, etc.

    0 讨论(0)
提交回复
热议问题