I need to convert a string like this:
A 'quote' is bold
into:
A \'quote\' is
mb_convert_encoding($string, "UTF-8", "HTML-ENTITIES");
You can replace "UTF-8" with whatever encoding you need (though depending on the encoding you choose, certain characters may not be representable).