Jump to content

How to display odd characters in HTML?


reportingsjr

Recommended Posts

Well, I'm making a chat and I have locales (language files), so a friend and I made a spanish one, but when the characters are put directly into the HTML they come out as the "unknown character" symbol (diamond with a question mark in it). What do I have to do to fix this? The content type is set as text/html, charset=UTF-8, so I don't know what to do.Thanks!By the way, to see an example of it visit http://rsbattlehelp.com/beta_lace/.

Link to comment
Share on other sites

Guest FirefoxRocks

If you have characters not in the UTF-8 character encoding, you need to try something else.If iso-8859-1 doesn't work, then it should be something else.

Link to comment
Share on other sites

Hmm, I changed it to iso-8859-1 and nothing happened. If utf-8 only has single byte characters then which one has double, or whatever it is? I swear that ascii had single byte and uft-8 had everything under the sun.

Link to comment
Share on other sites

Setting a meta tag is not enough. You must set the encoding to UTF-8 on the server too.With PHP, you can do that with the iconv extension (provided it's available) like so before any output:

iconv_set_encoding('output_encoding', 'UTF-8');

(note: I'm NOT sure if this will work; I usually set encodings at the server i.e. Apache level or more often, since I use XSLT, I leave the XML serializer deal with it)

UTF-8 only has single-byte characters, but I'm not sure why it isn't working.
No. It also has multy byte characters. Infact, UTF-8 is the defacto standard multy byte charset.
Link to comment
Share on other sites

Ok, I have these two for all files now:

mb_internal_encoding('UTF-8');iconv_set_encoding('output_encoding', 'UTF-8');

And, it still doesn't work. And that's what I was thinking about UTF-8, got me all confused :) .

Link to comment
Share on other sites

Are you sure the PHP file(s) and all others involved are saved as UTF-8? I mean from the editor (assuming notepad), could you select from wherever the "encoding" option and use "UTF-8" as value.

Link to comment
Share on other sites

Guest FirefoxRocks

Just a quick question here: In Notepad++, why do I have to save it as ANSI and not UTF-8? UTF-8 puts 4 strange characters in the beginning of my XML/HTML/PHP documents.

Link to comment
Share on other sites

Just a quick question here: In Notepad++, why do I have to save it as ANSI and not UTF-8? UTF-8 puts 4 strange characters in the beginning of my XML/HTML/PHP documents.
A bug in Notepad++ maybe? Do you get the same results with other editors? If not, that's sure to be the reason.
*sigh* Ok, to be able to view a font in a certain encoding, the font has to be in that encoding. Character encoding goes with font.
Actually, the font must support the craracter, which MAY or MAY NOT be in that encoding. So character encoding doesn't always go with fonts. That's why regardless of the encoding, you can still use entity reference, and have a character render properly regardless of the font in use.By the way, how do I switch languages? Have you actually thought about that one?
Link to comment
Share on other sites

It's supposed to be backend, and when I saved the files as utf-8 it must send output the browser so I can't edit headers anymore. -.- I'll change it back to bulgarian so you can see it.

Link to comment
Share on other sites

It's supposed to be backend, and when I saved the files as utf-8 it must send output the browser so I can't edit headers anymore. -.- I'll change it back to bulgarian so you can see it.
I meant whether you have a link for the end user could select a language... language negotiation... that sort of stuff.I've had that UTF-8 problem before too. Unless you can set .htaccess files, there's no viable workaround.... hmm... maybe use header() to send a
Content-type:text/html;charset=UTF-8

?

Link to comment
Share on other sites

I can use .htaccess, whats the code for the workaround?
AddCharset UTF-8 .php

for .htaccessand/or

header('Content-type:text/html;charset=utf-8');

in PHP. Again, the file must be saved as UTF-8 for this to work.

Link to comment
Share on other sites

AddCharset UTF-8 .php

for .htaccessand/or

header('Content-type:text/html;charset=utf-8');

in PHP. Again, the file must be saved as UTF-8 for this to work.

All of the files? Then I might have to switch editors for a bit, I'm cool by that though.
Link to comment
Share on other sites

All of the files? Then I might have to switch editors for a bit, I'm cool by that though.
No. Putting it only in one of the PHP files (that gets executed before any echoes) is enough for the PHP part. But yes, all files need to be saved as UTF-8 if that's what you meant.
Link to comment
Share on other sites

Ah, um, what editor should I switch to? I still want highlighting and such, but I need to be able to have it save files automatically as utf-8.
Dreamwaver can do it. Notepad can too. I don't know about any others. Feel free to experiment though. The Favorite HTML editors topic has tons of editors you can choose from.
Link to comment
Share on other sites

Yeah, I was reading it and realized context is being sold, so I just donated 25 pounds for the cause. Been reading that for a bit, now I'll update all of the files!

Link to comment
Share on other sites

Guest FirefoxRocks

I recommend Notepad++, it can do syntax highlighting in CSS, JavaScript, HTML, XML, PHP, ASP, SQL, VB, C#, C++, C, INI as well as other wacky programming languages.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...