/    Sign up×
Community /Pin to ProfileBookmark

UTF-8 charset not working via TXT flatfile

I’ve got a problem with this [URL=http://www.stadtaus.com/en/php_scripts/gallery_script/]excellent image gallery script[/URL].

It’s a PHP script where it’s possible via a TXT file to determine the order of images shown and add extra text.

My problem is that this PHP script doesn’t parse any UTF-8 special chars from the TXT file to the final HTML output, but shows the special charset codes (like “´” just as an example).

Is there anything I can do to modify the script, or, is this a commonly known quirk to PHP?

BTW. When editing this post I noticed this PHP based board parses UTF-8 special chars correctly. I’m sure there must be a solution to my headaches… ?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 22.2004 — [font=trebuchet ms]Try using the following on your output variables (whatever the problem is occurring on).[/font]

[code=php]
$var = str_replace("&", "&", $var);
[/code]
Copy linkTweet thisAlerts:
@philawebauthorSep 22.2004 — [B]Jona[/B],

Do you mean I should make some sort of replacement code in a PHP file for all the UTF-8 special chars?

Hmm. then I have to find out where to place those codes...
Copy linkTweet thisAlerts:
@JonaSep 22.2004 — [font=trebuchet ms]No, if the output is [/font][font=courier new]&#xxx[/font][font=trebuchet ms] then replace it so that it's [/font][font=courier new]&#xxx[/font][font=trebuchet ms]. This way they will automatically be translated to the appropriate symbols when placed on an HTML page.[/font]
Copy linkTweet thisAlerts:
@crh3675Sep 22.2004 — Try this:

<i>
</i>
function escapeentities($txt){
$len = strlen($txt);
$res = "";
for($i = 0; $i &lt; $len; ++$i) {
$ord = ord($txt{$i});
// check only non-standard chars <br/>
if($ord &gt;= 126){
$res .= "&amp;#".$ord.";";
}else{
$res.=$txt{$i};
}
}
return $res;
}
Copy linkTweet thisAlerts:
@philawebauthorSep 26.2004 — [B]Hello[/B],

I've been sick with the flue, so I haven't responded previosly, I'm very sorry! I'll check out your advice later today and come back. ?
×

Success!

Help @philaweb 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...