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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.