0

I have following string:

$str='Enzyme™ is a trademark';

Now I want to put this string in a CSV file like: 'Enzyme™ is a trademark', `because if "™" placed like as it is in CSV file, Magento import product setup simply escapes it.
Can anyone please help me on this issue as I googled a lot but not found a correct suggestion. Sorry 4 my bad english.

I tried following code:

htmlentities($db->col['title'], ENT_QUOTES | ENT_IGNORE, "UTF-8");//but it simply removes '™'<br> 
htmlentities($db->col['title'], ENT_QUOTES , "UTF-8"); //removes whole string <br>
Jite
  • 5,761
  • 2
  • 23
  • 37
AJ..
  • 19
  • 1
  • 5

1 Answers1

0

Using the global function htmlentities in php, you can convert a string with 'special characters' to one using html entities.

$variable = "Enzyme™ is a trademark";
$convertedVariable = htmlentities($variable);
echo $convertedVariable; // echos: Enzyme&trade; is a trademark
Jite
  • 5,761
  • 2
  • 23
  • 37
  • Yes but while putting it in CSV file, it appears again like " Enzyme™ " – AJ.. Nov 12 '14 at 08:14
  • Are you inserting the converted string or the original string into the CSV file? The `htmlentities` function do not change the original value (its not passed by reference) but returns a new value (the 'fixed' string). – Jite Nov 12 '14 at 08:15
  • 1
    @AJ.. Then you probably have [encoding problems](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through). – Sverri M. Olsen Nov 12 '14 at 08:19
  • I want to put the same string in CSV so that it could be reflected well on html page after importing is done. but my issue is, when it appears in CSV with it's original value, Magento simply escapes this row :( – AJ.. Nov 12 '14 at 08:20