Jump to content

Help with get_file_content


Evify

Recommended Posts

Hi everyone

 

I'm having some trouble with some charsets when using get_file_content function.

 

I made the followin PHP code:

<?php 
	$file = file_get_contents('omfirma.txt');
	$unescape = array('?','?','?','?','?','?');
	$escape = array('Æ','æ','Ø','ø','Å','å');
	$content = str_replace($unescape, $escape, $file);
	echo $content;
	?>

 

But when i run it the special chars it was supposed to change to HTML entities are displayed as black squares with a ? inside of it. Can you please help me and show me where im doing it wrong? :)

Link to comment
https://forums.phpfreaks.com/topic/267556-help-with-get_file_content/
Share on other sites

This hasn't got anything to do with file_get_contents (), but decoding HTML entities. For that, you'll want to use htmlspecialchars_decode ().

 

Also make sure that you've set the correct charset, and that all instances are using the same charset. I recommend using UTF-8, as it's the most compatible.

That hints towards trying to decode something as UTF-8, while it's encoded in a different charset.

Exactly where this error occurs I cannot tell you, because I don't have enough information to determine that. So you'll need to go through every step along the way, and make sure that you're using the same charset every step of the way. If that isn't possible, then you'll need to convert to the correct one at the earliest possible time.

 

For more information on how to do this, please see the PHP manual for Multi Byte string functions.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.