tags:

views:

107

answers:

3

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?

+6  A: 

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.

Tom Haigh
+1  A: 

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)

David Dorward
What is your setup in Komodo Edit for Default Editor Encoding?
shin
It is set to UTF-8
David Dorward
A: 

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