SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    0 Post(s)
    0 Thread(s)

    Post Replace special chars not tags, php trigered by html

    Good day to you all,
    I working on a code which take a txt file and display it through php, but this thing is triggered by ajax.

    in the txt files there is html tags and html special chars.

    What I'm trying to do is encode only the special chars.
    ex :

    Php read those character not a problem, it when I pass it by ajax that i get some weird chars like squares with a question mark.

    Does anybody have an idea on how I can fix this ?

    Here is the code that get triggered when i click on a ajax link :
    PHP Code:

    $textsechttb htmlentities($textsectb);
    I only need to replace the special char not the html tags.


  2. #2
    SitePoint Addict Mal Curtis's Avatar
    Join Date
    Jul 2009
    New Zealand
    14 Post(s)
    0 Thread(s)
    Sounds like it's returning a string encoded in a character set different to what your main page (the calling page) is using. Find out what character set your main page is using, and ensure it's sent through as the third parameter to the htmlentities function (see manual page).

    Oh, and the fourth parameter for double_encoding will ensure html tags are not double encoded.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts