Hi David,
I'm having a problem with a strange character in a product feed.
In the feed itself, the product is showing up as Productnameᆴ
When imported it shoes up as Productname�
Using search and replace for either of these characters doesn't seem to work. Most of the products in he feed are displaying like this.
Any ideas ?
Many thanks
Adrian
Hi David,
So what changes are needed in search and replace filter, to use as input characters given in hex?
Hi mj,
Here's the code for a new Search and Replace Hex filter as described above - paste into the end of your existing includes/filter.php, just before the closing PHP tag...
/*************************************************/
/* searchReplaceHex */
/*************************************************/
$filter_names["searchReplaceHex"] = "Search and Replace Hex";
function filter_searchReplaceHexConfigure($filter_data)
{
print "Search (HEX):<br />";
print "<input type='text' name='search' value='".widget_safe($filter_data["search"])."' />";
widget_errorGet("search");
print "<br /><br />";
print "Replace (ASCII):<br />";
print "<input type='text' name='replace' value='".widget_safe($filter_data["replace"])."' />";
widget_errorGet("replace");
}
function filter_searchReplaceHexValidate($filter_data)
{
if (!$filter_data["search"])
{
widget_errorSet("search","required field");
}
}
function filter_searchReplaceHexExec($filter_data,$text)
{
$search = pack("H*" , $filter_data["search"]);
return trim(str_replace($search,$filter_data["replace"],$text));
}
Search value provided as a "packed" hex string, with each character represented as 2 ASCII characters in the range 0-F, e.g.
00AEFF
Replacement text is plain text as per the normal Search and Replace.
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi Adrian,
Looks like a spurious character encoding error, i've helped another user with a similar thing before. Search and Replace as it stands won't be working because the actual characters in the feed have the raw character codes shown in the icon - FF and AE (in hex) in this case.
If you could email me your includes/filter.php i'll make a small modification to Search and Replace that will enable you to filter out those characters...
Cheers,
David.