Prevent Drupal from rewriting # as %23 in URLs I have a field where I am rewriting the output, trimming it and providing a read more link. The read more link contains a # because it's a page anchor that triggers a views accordion on the destination page.

Views is converting the # character into %23 in the actual displayed link, which is breaking the link.

How can I convert it back to a # character in the url?
function drupal_urlencode($text) {
  if (variable_get('clean_url', '0')) {
    return str_replace(array('%2F', '%3F', '%3D', '%26', '%2523'),
                       array('/', '?', '=', '&amp;', '#'),
                       urlencode($text));
  }
  else {
    return str_replace('%2F', '/', urlencode($text));
  }
}