You are here

function views_atom_sanitize in Views Atom 6

Same name and namespace in other branches
  1. 7 views_atom.module \views_atom_sanitize()

Sanitize a string for an atom feed.

Certain HTML character entities are not valid in XML and cause character encoding to go completely bananas. This function converts those characters to their unicode equivalents.

@link http://changelog.ca/log/2006/06/12/making_nbsp_work_with_xml_rss_and_atom

Parameters

$string: The string to sanitize. If any other data type is passed it is returned unaffected.

3 calls to views_atom_sanitize()
content_views_atom_render in ./views_atom.module
Implementation of hook_views_atom_render().
taxonomy_views_atom_render in ./views_atom.module
Implementation of hook_views_atom_render().
views_plugin_row_rdf_node::render in views/views_plugin_row_rdf_node.inc

File

./views_atom.module, line 113

Code

function views_atom_sanitize($string) {
  if (is_string($string)) {
    module_load_include('inc', 'views_atom', 'misc/html_entities');
    $replacements = views_atom_html_entities_to_numeric();
    $search = array_keys($replacements);
    $replace = array_values($replacements);
    $string = str_replace($search, $replace, $string);
  }
  return $string;
}