1

I have content stored in a Postgres DB, now everytime I call the content so that it gets displayed using php, i get funny squares in IE and funny square type question marks in Firefox?

Example below

    *  - March � May 2009

How do I remove this?

I do not have access to the server so can't adjust the encoding there, only have postgres DB details and FTP access to upload my files

Elitmiar
  • 35,072
  • 73
  • 180
  • 229
  • possible duplicate of [What is character encoding and why should I bother with it](http://stackoverflow.com/questions/10611455/what-is-character-encoding-and-why-should-i-bother-with-it) – Raedwald Apr 10 '15 at 12:38

4 Answers4

8

I would also recommend: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) by Joel Spolsky, I've read it only recently myself, it will definitely help you sort out your problems.

Kobi
  • 135,331
  • 41
  • 252
  • 292
6

You need to make sure that Postgres, PHP, and your browser all agree on the content encoding, and that you have an appropriate font selected in your browser. The simplest way to do that is to choose UTF8 for everything.

I don't know about PHP, but I do know about databases and browsers. First you need to find out if the database is UTF8. (From psql, I would do a "\l" and look at the encoding.) Then you need to find out if PHP supports UTF8 (I have no idea how you do that). Then you need to see if how those characters are being stored in the database by the PHP app. Then you need to figure out if the web server is correctly reporting the content encoding. (On Linux/Unix, I'd use the program "HEAD" (not "head") to see the headers its returning.) And then you need to figure out if your browser is using a font that supports UTF8.

Or, you could just make sure you only store ASCII and forget the rest of the world exists. Not recommended.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
4

Wrong charset somewhere. The characters could be stored wrong already in database, or you have wrong charset in meta tags on the page(try manually change charset in browser), or there could be problem with wrong encoding when page is communicating with database. Check this page http://www.postgresql.org/docs/8.2/static/multibyte.html for more informations. Try to have same encoding on all places, preferably UTF-8

Dolfa
  • 796
  • 4
  • 21
2

You have encoding issues. Make sure the encoding is set right in the database, in the html markup and make sure the files themselves are saved in proper encoding.

code_burgar
  • 12,025
  • 4
  • 35
  • 53