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
  • 398,947
  • 96
  • 818
  • 769
shin
  • 31,901
  • 69
  • 184
  • 271

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
  • 57,217
  • 21
  • 114
  • 142
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)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
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.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Alex Barrett
  • 16,175
  • 3
  • 52
  • 51