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.

Recommended Answers

All 3 Replies

<?php
$input = str_replace("£", "&pound;", $input);
?>

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

Kyle

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?

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.