Jump to content

How to display odd characters in HTML?


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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...