/    Sign up×
Community /Pin to ProfileBookmark

PHP File Characters

How do you force certain characters to appear correctly in a PHP file?

See below for an example.

[URL=http://i42.tinypic.com/2l8k7sp.png]The character that is suppose to appear.[/URL]

[URL=http://i41.tinypic.com/k9axl0.png]The character that is appearing in place of the character that is suppose to appear.[/URL]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJun 24.2009 — The problem is probably some discrepancy between character sets somewhere. I have found it easiest to make sure everything uses UTF-8 as this caters for pretty much any known characters (even klingon!) and is being updated all the time. Have a read of this:

http://developer.loftdigital.com/blog/php-utf-8-cheatsheet

One thing that isnt mentioned there which I've found in the past is to send a 'SET NAMES utf8' query after connecting so that inserted data is entered correctly as well read correctly.
Copy linkTweet thisAlerts:
@bokehJun 24.2009 — That charset is latin 1. Set the correct charset with an http header.
[code=php]header('Content-Type: text/html; charset=ISO-8859-1');[/code]
Copy linkTweet thisAlerts:
@Cory_RauthorJun 25.2009 — Here's my friends response to you, Mindzai.

Well the problem is I've already tried that and still no dice =

<?php header('Content-type: text/plain; charset=utf-8'); ?>
That's what I've been using on the query page, which if you view the source still displays it wrong. I know it's not the database however, since I can read the records there and see the characters all correctly (for example, σκοτάδ&#953?, and it's also in utf-8. So that's why I have no idea what's wrong with it...[/QUOTE]


Friends response to you, bokeh.

Also no dice, as expected since if the database can display it with utf-8, the page should be able to as well ?[/QUOTE]
Copy linkTweet thisAlerts:
@Cory_RauthorJul 07.2009 — Anymore feedback?
Copy linkTweet thisAlerts:
@SyCoJul 07.2009 — I think you can to use htmlentities() and html_entity_decode() It's how I've handled Portuguese characters in a English based site.
×

Success!

Help @Cory_R spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...