Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations danielledunham on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange accents in php output with MacOs X 1

Status
Not open for further replies.

papyG

Programmer
Joined
Aug 12, 2004
Messages
8
Location
CH
Usually, when I typed
echo "é"; // echo an eacute caracter
in a php file, the output file would display the same character and thus be correctly interpreted by the major browsers (Explorer, Netscape, Safari).

Now I'm using Php 4.3.6 (entropy release) (under MacOs X 10.3.5) and I get strange characters in the output file.

Before, I used Php 4.2.x (official apple version) on a MacOs X Server (10.2.4)

What could I do to go on using the short way to type in specials caracters (instead of using the html encodings) ?

Thanks for any help !
 
é (eacute) is displayed as Ž (a Z with a cup on it) by Safari.
When I copy this character from the Safari screen back to BBedit, I get a question mark (?)
If I copy the same character from the Safari source back to BBEdit, I get two characters :
 
Why not simply write a function to do the conversion for you? One may exist in PHP already .... I don't know?!

... something like this example:

Code:
<?php
  function entityFilter($input) {
    $filter = str_replace("é", "&eacute;", $input); 
    $filter = str_replace("ê", "&ecirc;", $filter); 
    $filter = str_replace("è", "&egrave;", $filter); 
    return $filter;
  }

  $originalText = "Just testing : é ê è";
  $browserText = entityFilter($originalText);

  echo "Before == $originalText <HR>";
  echo "After == $browserText";
?>

Here's a HTML entity reference for your convienance:


Good luck §:O)


Jakob
 
Thank you for your code; it works perfectly.

Nevertheless, using this function is less convenient than juste typing the original characters.

I think the special characters from BBedit are not translated in the right way when passed to Unix and Php. This also explains why htmlentities() does not work and why the above code does.

Has the $LANG variable any influence on that ?
 
Well, I don't know BBEdit (being a PC user). However, I Googled it and came up with a character translation extension for BBEdit : "MIDex" -it's free and works in both versions.

Maybe this is the problem?! Anyway - here's the link:


Good Luck §;O)


Jakob
 
Great ! It works when making a Mac-Iso conversion… This simplifies my programming even if it is still not as easy as before…

Nevertheless, may be some change in the configuration of Unix or Php could also resolve the problem, but which (I'm really not familiar with Unix…)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top