We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

fwrite .txt file pound sign encoding error £

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.

3
Contributors
3
Replies
1 Day
Discussion Span
3 Years Ago
Last Updated
4
Views
MaxMumford
Posting Whiz in Training
228 posts since Oct 2006
Reputation Points: 32
Solved Threads: 3
Skill Endorsements: 0
<?php
$input = str_replace("£", "&pound;", $input);
?>

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

Kyle

diskhub
Newbie Poster
10 posts since Nov 2007
Reputation Points: 10
Solved Threads: 4
Skill Endorsements: 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?

MaxMumford
Posting Whiz in Training
228 posts since Oct 2006
Reputation Points: 32
Solved Threads: 3
Skill Endorsements: 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)

almostbob
Nearly a Senior Poster
3,303 posts since Jan 2009
Reputation Points: 585
Solved Threads: 403
Skill Endorsements: 7

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0618 seconds using 2.65MB