Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Encode Special Characters

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33970
    aoeui
    Participant

    hi,

    I never figured this out, what is meant by encoding special characters?

    there are reserved characters in HTML, ok we know it

    "	"
    ' '
    & &
    < <
    > >

    but what all should we encode in the body, text etc.?
    every single asterisk, brackets, quotation mark, exclamation mark … I dunno

    even stuff like this?

    (
    )
    *
    !
    ?
    [
    ]
    /
    +
    -
    #85223
    jamygolden
    Member

    I think people generally encode things that could break their code… for example:

    The apostrophe contained within “isn’t” will close the echo and cause some kind of error. Therefore that would be changed to something like:

    And the same with HTML. In order to get a less than character in these forums ( < ) we have to use the code, otherwise it will be seen as code. So something like a * and () only needs to be encoded where appropriate.

    for the most part, I just deal with <, >, & and ‘

    #85227
    jamygolden
    Member

    Yeah, that’s fine :)

    #85229
    jamygolden
    Member

    When you create a web page, send it through the validator. If it succeeds, you’re all good.

    I don’t think I’ve ever encoded:

    (
    )
    *
    !
    ?
    [
    ]
    /
    +
    -

    Via the html codes. If I want to escape something in php, I’ll do something like escape($foo);
    jQuery seems to escape strings (at least most that I’ve used) for me. It’s pretty smart: for example

    $('body').prepend('&');
    $('body').prepend('&');

    will put
    & in the body, which will display as &

    If I want to use a ‘ in a js string. Instead of doing this
    $('body').prepend('This won't work');
    I’ll do this:
    $('body').prepend("This won't work");

    You don’t need to really worry about all that too much :p

    #85234
    chrisburton
    Participant

    @jamy_za But…but..what about..

    Edit: Well, I should not skim the article. However, I don’t think everything is necessary to encode. If you have a word that has an apostrophe, use double quotes. You should probably use them anyway just to avoid the issue.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.