Log in

View Full Version : Resolved Special characters in text don't display



Doomtomb
04-19-2010, 02:01 PM
Hey guys, I have an issue on my website that I'm making. Certain characters aren't displayed correctly and come up as question marks. Like "" (quotes) and (c) (copyright symbol) and what not. I am using Arial font. The page is saved as php but it's mostly html. I just use php for the include statements.

Here's a link:
http://www.istarjrconsulting.com/leadership_team.php

djr33
04-19-2010, 05:25 PM
There are a few reasons for this. All of them relate to character encoding. Basically using all the 1s and 0s, there are many ways to represent a certain character. Different encodings are different systems for this.
So, explain exactly how you created these pages and the text, what programs, whether you cut/paste, etc. Is the text stored in a database? What format is the database in?

The easy answer may be to change the encoding of the HTML document itself, but this can also be generated from (for example) saving an HTML file from an MS Word document, or even in some cases just cutting and pasting from Word.

The complexity here is that without being able to play with the page it's hard to guess why this happens. Additionally, it could even be that it works on some systems and not others. This happens with unusual characters, but not normal punctuation, so it's likely an encoding issue, not a missing font, etc.

Doomtomb
04-19-2010, 05:48 PM
There are a few reasons for this. All of them relate to character encoding. Basically using all the 1s and 0s, there are many ways to represent a certain character. Different encodings are different systems for this.
So, explain exactly how you created these pages and the text, what programs, whether you cut/paste, etc. Is the text stored in a database? What format is the database in?

The easy answer may be to change the encoding of the HTML document itself, but this can also be generated from (for example) saving an HTML file from an MS Word document, or even in some cases just cutting and pasting from Word.

The complexity here is that without being able to play with the page it's hard to guess why this happens. Additionally, it could even be that it works on some systems and not others. This happens with unusual characters, but not normal punctuation, so it's likely an encoding issue, not a missing font, etc.
Ok, I gave you a big thank you for this post. Alright, so it has to do with the encoding. I saved this page in Notepad++ as a .php. Then I uploaded it to the server via FTP. How do I change the encoding and which encoding should I use?

I paused while writing this post, I went into my file editor on the web host and saved it as utf-8 encoding and it works now. I never knew this bit about encodings. My only question is how do I save my files in Notepad++ with the correct encoding? In this case utf-8.

EDIT:
Ok, I found it was right in front of my face in an option called "Encoding" on the top bar. I'll call this case solved now.

djr33
04-19-2010, 07:18 PM
There can be varied encodings at any level and this is a real problem. The file itself is encoded in one, the HTML document has a tag that specifics an encoding (if you choose, or the browser's default is used), the text in a database is encoded, and the original text that you cut and paste or type is encoded in something too. To avoid errors, they all must match.
I use UTF8 because I don't work with just English. Any consistent format should be fine, though UTF8 is the most compatible with all characters. It's said to be slow or something, but I don't really mind.

That all said, now all you need to do is figure out how to, at every point in the process, control the format.

I don't use notepad++, but if it's similar to notepad, there will just be a dropdown menu while you save the file (like when you choose a format of .doc, .rtf or .txt in Word), and you can pick UTF8 and other things. (Note: UTF8 is called Unicode sometimes, so that should work too. UTF8 = 8 bit unicode; 16 also exists, though it's less common.)

You should be able to search google/the help menu for it-- notepad++ is a good program. It should have this feature.
However some programs actually just don't have an option-- I never did find it in dreamweaver (though I was using an old version, but after installing a demo of the new one I didn't find it either). For this reason I ended up not using it any more and now I just use a simpler program that I actually like better overall, but that was the main reason to change it.

traq
04-20-2010, 12:57 AM
You may be better off (e.g., if you ever start working with .htaccess) selecting the option "UTF-8 without BOM". But for most applications, it won't matter. Make sure your html charset declaration matches whatever you choose.

djr: you should give notepad++ a try. lotsa cool features, not the least of which is syntax highlighting. Eliminates a LOT of simple mistakes.

djr33
04-20-2010, 01:31 AM
I am on a mac so I can't use notepad++, but I use text wrangler which is about the same from what I can tell. It's nice to work with.

traq
04-20-2010, 02:07 AM
hmm... Apparently it can run on OSX using a windows emulator of some sort (and although I don't really liking Mac, I think that running Windows on a Mac is completely ridiculous). And if you already have something with similar functionality, cool.

BTW I also found this, thought it funny

Why notepad++ doesn't (and never will) work on Linux
http://notepad-plus.sourceforge.net/commun/images/linux-evil.png

djr33
04-20-2010, 02:40 AM
You can run anything with an emulator of course, but it is always very slow. With parallels and such now it's possible to run things near-natively, but I'm not sure of the point of that. Though in the case of a text editor, it doesn't really matter how slowly it's running, though I imagine even that would manage to crash the older forms of virtual pc and whatnot, running on borrowed ram, a file acting as a disc and other nonsense :p