Jump to content

Parsing problem


karmacrow

Recommended Posts

Hi everyone I am trying to replace some specific characters in a file but I am not being able to do this. It is a type of apostrophe...

 

For example in the following text excerpt

 

<td class="card" align='left'>
  Night’s Whisper
</td>

 

I would like to replace the

in the word Night. However when putting the file contents into a string (via fopen and co) and the using

 

$contents = str_replace("’","'",$contents);

 

nothing happens, and nothing is replaced. How can I replace this type of characters. I have very little idea about text encoding and the likes so any help will be heavily appreciated.

 

Thanks a lot

Link to comment
https://forums.phpfreaks.com/topic/37434-parsing-problem/
Share on other sites

Your code works for me. Those quotes are called "Smart Quotes" and are part of the Windows-1252 encoding. You can try using mb_convert_encoding to see if the quotes will "return to normal," or you can use regular expressions to replace them; their values are below:

0x91 - Left single quote

0x92 - Right single quote

0x93 - Left double quote

0x94 - Right double quote

Link to comment
https://forums.phpfreaks.com/topic/37434-parsing-problem/#findComment-179186
Share on other sites

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.