1

I've been working on a website recently (localhost environment). Today I made it online and I encountred a really wierd problem :

When ever I try to output UTF-8 characters (hebrew) from my database it works perfectly, but when I try to echo simple text (ex: echo "שלום";) I get question marks (not the ones with the black background).

I've tried to search for a solution but found none. I hope you guys can help me with this

3 Answers3

1

Things to check:

  1. Did you try telling the client browser what character set you're using: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> (<meta charset="utf-8"> vs <meta http-equiv="Content-Type">)

  2. Is your file/editor set for UTF-8? Eclipse defaults to cp1252, common windows editors will default to ISO-8859-1 or UCS-2.

  3. In your php.ini file, confirm default_charset = "UTF-8" (see http://www.php.net/manual/en/ini.core.php#ini.default-charset)

  4. Force the content type in the HTTP transaction (via response header): header('Content-type: text/html; charset=utf-8'); Be sure to include this before any content is flushed to the browser.

Community
  • 1
  • 1
zamnuts
  • 9,492
  • 3
  • 39
  • 46
  • 1. Yes, I have tried both of them but none work. 2. Also yes. I have checked it and its UTF-8, I use dreamweaver if it helps you somehow – user2012389 Mar 28 '13 at 00:43
  • @user2012389 what if you just put those characters in plain html... bypassing PHP? – zamnuts Mar 28 '13 at 00:48
  • if you have access to your php.ini: `default_charset = "UTF-8"` (see http://www.php.net/manual/en/ini.core.php#ini.default-charset) – zamnuts Mar 28 '13 at 00:50
  • What do I do if I don't have access to my PHP.ini? – user2012389 Mar 28 '13 at 00:57
  • 1
    @user2012389 I really think it is a problem with dreamweaver (http://hsmoore.com/how-to-save-a-dreamweaver-document-as-utf8/ - if this works, i'll update my answer accordingly). You can use ini_set or simply omit editing the php.ini and do #4 (http://stackoverflow.com/questions/8229696/do-i-need-to-set-ini-set-default-charset-utf-8). – zamnuts Mar 28 '13 at 00:59
  • Okay, I now noticed a really wierd thing. My website has an Admin Panel I made (myweb.com/panel), and hebrew works perfectly there.. And I tried all the things you told me to try but again, none worked. I srsly dont understand this.. – user2012389 Mar 28 '13 at 01:11
0

Your encoding is wrong in your code files. Your editor saved them wrong, and you probably did not bother to also send a HTTP header for "Content-type", and your localhost also did not, but your online server now does.

Change the encoding, and all will be well.

Sven
  • 69,403
  • 10
  • 107
  • 109
0

I had this problem recently. Use this code to solve it:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
Mansour Fahad
  • 48
  • 1
  • 2
  • 7