Some characters become “�” in our webpage











up vote
1
down vote

favorite












I use PHP to access a database to get a string like this




‘Chloe’ Fashion Show & Dinner




and then I do a printf() to output the string as html, but my webpage shows this:




�Chloe� Fashion Show & Dinner




All contents are English-based, do I miss something in PHP?



Where should I be checking?










share|improve this question




















  • 1




    Do you have the utf8 meta tag ?
    – Patsy Issa
    Oct 31 '13 at 9:29










  • Add utf8 meta tag in HTML page ..
    – Akhil Thayyil
    Oct 31 '13 at 9:30










  • <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    – Akhil Thayyil
    Oct 31 '13 at 9:30






  • 1




    Check for the document's character set. You can see and change with a code editor like "Notepad++". Try to convert utf8.
    – R. Canser Yanbakan
    Oct 31 '13 at 9:31










  • mysqli_set_charset($link, "utf8") solves the problem, thanks a lot guys.
    – Joe Huang
    Oct 31 '13 at 10:00















up vote
1
down vote

favorite












I use PHP to access a database to get a string like this




‘Chloe’ Fashion Show & Dinner




and then I do a printf() to output the string as html, but my webpage shows this:




�Chloe� Fashion Show & Dinner




All contents are English-based, do I miss something in PHP?



Where should I be checking?










share|improve this question




















  • 1




    Do you have the utf8 meta tag ?
    – Patsy Issa
    Oct 31 '13 at 9:29










  • Add utf8 meta tag in HTML page ..
    – Akhil Thayyil
    Oct 31 '13 at 9:30










  • <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    – Akhil Thayyil
    Oct 31 '13 at 9:30






  • 1




    Check for the document's character set. You can see and change with a code editor like "Notepad++". Try to convert utf8.
    – R. Canser Yanbakan
    Oct 31 '13 at 9:31










  • mysqli_set_charset($link, "utf8") solves the problem, thanks a lot guys.
    – Joe Huang
    Oct 31 '13 at 10:00













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I use PHP to access a database to get a string like this




‘Chloe’ Fashion Show & Dinner




and then I do a printf() to output the string as html, but my webpage shows this:




�Chloe� Fashion Show & Dinner




All contents are English-based, do I miss something in PHP?



Where should I be checking?










share|improve this question















I use PHP to access a database to get a string like this




‘Chloe’ Fashion Show & Dinner




and then I do a printf() to output the string as html, but my webpage shows this:




�Chloe� Fashion Show & Dinner




All contents are English-based, do I miss something in PHP?



Where should I be checking?







php string encoding






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 6:59









Cœur

17.1k9102140




17.1k9102140










asked Oct 31 '13 at 9:28









Joe Huang

3,74242459




3,74242459








  • 1




    Do you have the utf8 meta tag ?
    – Patsy Issa
    Oct 31 '13 at 9:29










  • Add utf8 meta tag in HTML page ..
    – Akhil Thayyil
    Oct 31 '13 at 9:30










  • <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    – Akhil Thayyil
    Oct 31 '13 at 9:30






  • 1




    Check for the document's character set. You can see and change with a code editor like "Notepad++". Try to convert utf8.
    – R. Canser Yanbakan
    Oct 31 '13 at 9:31










  • mysqli_set_charset($link, "utf8") solves the problem, thanks a lot guys.
    – Joe Huang
    Oct 31 '13 at 10:00














  • 1




    Do you have the utf8 meta tag ?
    – Patsy Issa
    Oct 31 '13 at 9:29










  • Add utf8 meta tag in HTML page ..
    – Akhil Thayyil
    Oct 31 '13 at 9:30










  • <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    – Akhil Thayyil
    Oct 31 '13 at 9:30






  • 1




    Check for the document's character set. You can see and change with a code editor like "Notepad++". Try to convert utf8.
    – R. Canser Yanbakan
    Oct 31 '13 at 9:31










  • mysqli_set_charset($link, "utf8") solves the problem, thanks a lot guys.
    – Joe Huang
    Oct 31 '13 at 10:00








1




1




Do you have the utf8 meta tag ?
– Patsy Issa
Oct 31 '13 at 9:29




Do you have the utf8 meta tag ?
– Patsy Issa
Oct 31 '13 at 9:29












Add utf8 meta tag in HTML page ..
– Akhil Thayyil
Oct 31 '13 at 9:30




Add utf8 meta tag in HTML page ..
– Akhil Thayyil
Oct 31 '13 at 9:30












<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
– Akhil Thayyil
Oct 31 '13 at 9:30




<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
– Akhil Thayyil
Oct 31 '13 at 9:30




1




1




Check for the document's character set. You can see and change with a code editor like "Notepad++". Try to convert utf8.
– R. Canser Yanbakan
Oct 31 '13 at 9:31




Check for the document's character set. You can see and change with a code editor like "Notepad++". Try to convert utf8.
– R. Canser Yanbakan
Oct 31 '13 at 9:31












mysqli_set_charset($link, "utf8") solves the problem, thanks a lot guys.
– Joe Huang
Oct 31 '13 at 10:00




mysqli_set_charset($link, "utf8") solves the problem, thanks a lot guys.
– Joe Huang
Oct 31 '13 at 10:00












3 Answers
3






active

oldest

votes

















up vote
6
down vote



accepted











  1. Check if your .php file is encoded as UTF-8 without BOM

  2. Check that your connection to the database is UTF-8

  3. Check that you send <meta charset="utf-8"> in your HTML markup in the <head> tag


If your connection to the database is not UTF-8 and you don't want to change it (but I recommend it -> everything UTF-8 is the most secure solution against character rubbish) use utf8_encode($databaseValue) to ensure the encoding of your value is UTF-8.






share|improve this answer



















  • 1




    I'd also check Apache/PHP config to send default charset utf8, mostly the problem is the first point you mention anyways, the file contents itself should be utf8 of course
    – DanFromGermany
    Oct 31 '13 at 9:33












  • I use utf8_encode and characters are not there anymore. However, the original characters are gone too. It's kind of weird.
    – Joe Huang
    Oct 31 '13 at 9:52










  • Have you checked and fixed all 3 points of my checklist?
    – TiMESPLiNTER
    Oct 31 '13 at 9:53






  • 1




    mysqli_set_charset($link, "utf8") solves the problem, thanks a lot.
    – Joe Huang
    Oct 31 '13 at 9:57


















up vote
1
down vote













Make sure that you use:



<meta charset="utf-8"> 


in the head of your page.






share|improve this answer




























    up vote
    1
    down vote













    You need to add charset meta tag in 'head' section of html.
    Note that the meta tag must appear within the first 1024 bytes of rendered page.



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





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19702687%2fsome-characters-become-in-our-webpage%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      6
      down vote



      accepted











      1. Check if your .php file is encoded as UTF-8 without BOM

      2. Check that your connection to the database is UTF-8

      3. Check that you send <meta charset="utf-8"> in your HTML markup in the <head> tag


      If your connection to the database is not UTF-8 and you don't want to change it (but I recommend it -> everything UTF-8 is the most secure solution against character rubbish) use utf8_encode($databaseValue) to ensure the encoding of your value is UTF-8.






      share|improve this answer



















      • 1




        I'd also check Apache/PHP config to send default charset utf8, mostly the problem is the first point you mention anyways, the file contents itself should be utf8 of course
        – DanFromGermany
        Oct 31 '13 at 9:33












      • I use utf8_encode and characters are not there anymore. However, the original characters are gone too. It's kind of weird.
        – Joe Huang
        Oct 31 '13 at 9:52










      • Have you checked and fixed all 3 points of my checklist?
        – TiMESPLiNTER
        Oct 31 '13 at 9:53






      • 1




        mysqli_set_charset($link, "utf8") solves the problem, thanks a lot.
        – Joe Huang
        Oct 31 '13 at 9:57















      up vote
      6
      down vote



      accepted











      1. Check if your .php file is encoded as UTF-8 without BOM

      2. Check that your connection to the database is UTF-8

      3. Check that you send <meta charset="utf-8"> in your HTML markup in the <head> tag


      If your connection to the database is not UTF-8 and you don't want to change it (but I recommend it -> everything UTF-8 is the most secure solution against character rubbish) use utf8_encode($databaseValue) to ensure the encoding of your value is UTF-8.






      share|improve this answer



















      • 1




        I'd also check Apache/PHP config to send default charset utf8, mostly the problem is the first point you mention anyways, the file contents itself should be utf8 of course
        – DanFromGermany
        Oct 31 '13 at 9:33












      • I use utf8_encode and characters are not there anymore. However, the original characters are gone too. It's kind of weird.
        – Joe Huang
        Oct 31 '13 at 9:52










      • Have you checked and fixed all 3 points of my checklist?
        – TiMESPLiNTER
        Oct 31 '13 at 9:53






      • 1




        mysqli_set_charset($link, "utf8") solves the problem, thanks a lot.
        – Joe Huang
        Oct 31 '13 at 9:57













      up vote
      6
      down vote



      accepted







      up vote
      6
      down vote



      accepted







      1. Check if your .php file is encoded as UTF-8 without BOM

      2. Check that your connection to the database is UTF-8

      3. Check that you send <meta charset="utf-8"> in your HTML markup in the <head> tag


      If your connection to the database is not UTF-8 and you don't want to change it (but I recommend it -> everything UTF-8 is the most secure solution against character rubbish) use utf8_encode($databaseValue) to ensure the encoding of your value is UTF-8.






      share|improve this answer















      1. Check if your .php file is encoded as UTF-8 without BOM

      2. Check that your connection to the database is UTF-8

      3. Check that you send <meta charset="utf-8"> in your HTML markup in the <head> tag


      If your connection to the database is not UTF-8 and you don't want to change it (but I recommend it -> everything UTF-8 is the most secure solution against character rubbish) use utf8_encode($databaseValue) to ensure the encoding of your value is UTF-8.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jan 9 '14 at 8:02

























      answered Oct 31 '13 at 9:31









      TiMESPLiNTER

      4,19811547




      4,19811547








      • 1




        I'd also check Apache/PHP config to send default charset utf8, mostly the problem is the first point you mention anyways, the file contents itself should be utf8 of course
        – DanFromGermany
        Oct 31 '13 at 9:33












      • I use utf8_encode and characters are not there anymore. However, the original characters are gone too. It's kind of weird.
        – Joe Huang
        Oct 31 '13 at 9:52










      • Have you checked and fixed all 3 points of my checklist?
        – TiMESPLiNTER
        Oct 31 '13 at 9:53






      • 1




        mysqli_set_charset($link, "utf8") solves the problem, thanks a lot.
        – Joe Huang
        Oct 31 '13 at 9:57














      • 1




        I'd also check Apache/PHP config to send default charset utf8, mostly the problem is the first point you mention anyways, the file contents itself should be utf8 of course
        – DanFromGermany
        Oct 31 '13 at 9:33












      • I use utf8_encode and characters are not there anymore. However, the original characters are gone too. It's kind of weird.
        – Joe Huang
        Oct 31 '13 at 9:52










      • Have you checked and fixed all 3 points of my checklist?
        – TiMESPLiNTER
        Oct 31 '13 at 9:53






      • 1




        mysqli_set_charset($link, "utf8") solves the problem, thanks a lot.
        – Joe Huang
        Oct 31 '13 at 9:57








      1




      1




      I'd also check Apache/PHP config to send default charset utf8, mostly the problem is the first point you mention anyways, the file contents itself should be utf8 of course
      – DanFromGermany
      Oct 31 '13 at 9:33






      I'd also check Apache/PHP config to send default charset utf8, mostly the problem is the first point you mention anyways, the file contents itself should be utf8 of course
      – DanFromGermany
      Oct 31 '13 at 9:33














      I use utf8_encode and characters are not there anymore. However, the original characters are gone too. It's kind of weird.
      – Joe Huang
      Oct 31 '13 at 9:52




      I use utf8_encode and characters are not there anymore. However, the original characters are gone too. It's kind of weird.
      – Joe Huang
      Oct 31 '13 at 9:52












      Have you checked and fixed all 3 points of my checklist?
      – TiMESPLiNTER
      Oct 31 '13 at 9:53




      Have you checked and fixed all 3 points of my checklist?
      – TiMESPLiNTER
      Oct 31 '13 at 9:53




      1




      1




      mysqli_set_charset($link, "utf8") solves the problem, thanks a lot.
      – Joe Huang
      Oct 31 '13 at 9:57




      mysqli_set_charset($link, "utf8") solves the problem, thanks a lot.
      – Joe Huang
      Oct 31 '13 at 9:57












      up vote
      1
      down vote













      Make sure that you use:



      <meta charset="utf-8"> 


      in the head of your page.






      share|improve this answer

























        up vote
        1
        down vote













        Make sure that you use:



        <meta charset="utf-8"> 


        in the head of your page.






        share|improve this answer























          up vote
          1
          down vote










          up vote
          1
          down vote









          Make sure that you use:



          <meta charset="utf-8"> 


          in the head of your page.






          share|improve this answer












          Make sure that you use:



          <meta charset="utf-8"> 


          in the head of your page.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 31 '13 at 9:31









          Wayne Whitty

          15.3k33358




          15.3k33358






















              up vote
              1
              down vote













              You need to add charset meta tag in 'head' section of html.
              Note that the meta tag must appear within the first 1024 bytes of rendered page.



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





              share|improve this answer



























                up vote
                1
                down vote













                You need to add charset meta tag in 'head' section of html.
                Note that the meta tag must appear within the first 1024 bytes of rendered page.



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





                share|improve this answer

























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  You need to add charset meta tag in 'head' section of html.
                  Note that the meta tag must appear within the first 1024 bytes of rendered page.



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





                  share|improve this answer














                  You need to add charset meta tag in 'head' section of html.
                  Note that the meta tag must appear within the first 1024 bytes of rendered page.



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






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Oct 31 '13 at 11:08









                  Joran Den Houting

                  2,74431647




                  2,74431647










                  answered Oct 31 '13 at 9:31









                  jondinham

                  4,7041260119




                  4,7041260119






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19702687%2fsome-characters-become-in-our-webpage%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      The Sandy Post

                      Danny Elfman

                      Pages that link to "Head v. Amoskeag Manufacturing Co."