WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] special character code ’ instead of apostraphe (4 posts)

  1. jeremyduffy
    Member
    Posted 4 years ago #

    This is a hard problem to diagnose. I am trying to send a page title to a Javascript variable but it's showing that darned html character code or utf8 char code. How do I get rid of it? There must be a wordpress function or something that does this.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Could you run something like urldecode or html-entity-decode on the title to decode the special characters before passing them onto your javascript?

  3. jeremyduffy
    Member
    Posted 4 years ago #

    I tried both and no dice. The character code didn't come through in my original comment which is also why it's hard to search on, but it's & #8217;

  4. jeremyduffy
    Member
    Posted 4 years ago #

    I don't know how to make it a regular apostrophe again, but using this:

    return html_entity_decode($string, ENT_QUOTES, 'UTF-8')

    I was able to get it to at least a funky character code that looks like an apostrophe. It works for now anyway.

Topic Closed

This topic has been closed to new replies.

About this Topic