1,105,423 Community Members

fwrite .txt file pound sign encoding error £

Member Avatar
MDGM
Posting Whiz in Training
229 posts since Oct 2006
Reputation Points: 22 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

hi all,

I have a php script that saves what the user types in into a text file using fwrite, and displays it on another page using file_get_contents.

When putting in a pound sign (£), it saves the following to the text file:

£

Any idea how I can stop this from happening and instead get the pound sign working properly?

Max.

Member Avatar
diskhub
Newbie Poster
10 posts since Nov 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
0
 
<?php
$input = str_replace("£", "&pound;", $input);
?>

where $input is the string you are entering into a text file.

Kyle

Member Avatar
MDGM
Posting Whiz in Training
229 posts since Oct 2006
Reputation Points: 22 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

iv tried that but cant get any changes working. its quite a complex problem and I have tried many possible solutions... if anybody else has had the same thing that would be best.

I think its an encoding charset discrepency?

Member Avatar
almostbob
Nearly a Senior Poster
3,395 posts since Jan 2009
Reputation Points: 515 [?]
Q&As Helped to Solve: 425 [?]
Skill Endorsements: 14 [?]
 
0
 

UTF-8 encoding
html charset
the GBP pound sign gets 2 bytes in utf8 utf16 its not one of the lower 127 ascii codes that gets directly translated
the page that reads the stored data file needs to be charset UTF-8,
logically aware of the answer, my phone does not have my stored links on it so I cant post the relevant link
(anti boredom browsing)

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: