Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-1439

Google geocode error when processing accented characters

    Details

      Description

      When tyring to geocode an address with french accents an error is generated.

      " warning: simplexml_load_string() [function.simplexml-load-string]:
      Entity: line 1: parser error : Input is not proper UTF-8 "

      The error is in line Google.php line 107

      $xml = simplexml_load_string( $string );

      The can be fixed with a small function to remove accents.

      A function to do this could be

      function unaccent($text) {
      static $search, $replace;
      if (!$search) {
      $search = $replace = array();
      // Get the HTML entities table into an array
      $trans = get_html_translation_table(HTML_ENTITIES);
      // Go through the entity mappings one-by-one
      foreach ($trans as $literal => $entity) {
      // Make sure we don't process any other characters
      // such as fractions, quotes etc:
      if (ord($literal) >= 192)

      { // Get the accented form of the letter $search[] = $literal; // Get e.g. 'E' from the string '&Eacute' $replace[] = $entity[1]; }

      }
      }
      return str_replace($search, $replace, $text);
      }

      and line 107 would now be

      $xml = simplexml_load_string( unaccent($string) );

        Attachments

          Activity

            People

            • Assignee:
              sameermare Sameer Mare
              Reporter:
              cdhawk Curtis Delaney
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: