You are here:  » Problem with character in feed


Problem with character in feed

Submitted by paddyman on Thu, 2009-04-30 18:02 in

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

Submitted by support on Fri, 2009-05-01 08:08

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.

Submitted by mj_2000 on Mon, 2011-03-14 18:03

Hi David,

So what changes are needed in search and replace filter, to use as input characters given in hex?

Submitted by support on Mon, 2011-03-14 18:24

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

Submitted by mj_2000 on Tue, 2011-03-15 10:04

Thank you David!