2

I am using notepad++ for php coding.

I don't have any problem with format set up using Encode in ANSI.

However when I use Encode in UTF-8, either I have a strange character at the top or not showing anything.

Q1. Am I supposed to use ANSI? Q2. Why do I am not able to display anything when I use UTF-8

My sourse code for the header is following.

<html>
<head>
<title>Hello, PHPlot!</title>
</head>

Is that because I am not using UTF-8 in the header?

skaffman
  • 390,936
  • 96
  • 800
  • 764
shin
  • 30,521
  • 65
  • 174
  • 258

3 Answers3

7

It's probably a Byte Order Mark. You can use the 'Encode in UTF-8 without BOM' mode in notepad++.

This question has some helpful information about using UTF-8 with PHP. You will also (as you suggested) need to set the content type in either the header or a meta tag in order for the browser to interpret it correctly.

Community
  • 1
  • 1
Tom Haigh
  • 56,170
  • 20
  • 110
  • 140
0

It sounds like you are using UTF-8 with a BOM (which has issues) and your server is failing to specify the encoding correctly.

IIRC, BOM is unavoidable in Notepad, so I would suggest using a better editor. I'm fond of Komodo Edit myself.

(Also note, that a Doctype is required in HTML documents)

Quentin
  • 857,932
  • 118
  • 1,152
  • 1,264
0

As Tom Haigh says, it's probably the BOM. It's not necessary for UTF-8 encoding, so you can safely leave them out.

However I should point out that PHP has very weak support for UTF-8 - be prepared for a bumpy ride. Take a look at this page for some details on problems you might encounter.

Alex Barrett
  • 15,546
  • 3
  • 50
  • 51