Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #9776 > unrolled thread

JavaScript's Character Escaping Functions

Started byGene Wirchenko <genew@ocis.net>
First post2011-12-29 17:30 -0800
Last post2011-12-31 20:41 +0000
Articles 10 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  JavaScript's Character Escaping Functions Gene Wirchenko <genew@ocis.net> - 2011-12-29 17:30 -0800
    Re: JavaScript's Character Escaping Functions Tim Streater <timstreater@greenbee.net> - 2011-12-30 10:33 +0000
      Re: JavaScript's Character Escaping Functions Gene Wirchenko <genew@ocis.net> - 2011-12-30 11:45 -0800
        Re: JavaScript's Character Escaping Functions "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-12-30 22:06 +0200
        Re: JavaScript's Character Escaping Functions Tim Streater <timstreater@greenbee.net> - 2011-12-30 22:45 +0000
    Re: JavaScript's Character Escaping Functions "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2011-12-30 12:03 -0800
    Re: JavaScript's Character Escaping Functions Denis McMahon <denismfmcmahon@gmail.com> - 2011-12-31 10:05 +0000
      Re: JavaScript's Character Escaping Functions Gene Wirchenko <genew@ocis.net> - 2011-12-31 23:41 -0800
        Re: JavaScript's Character Escaping Functions Dr J R Stockton <reply1152@merlyn.demon.co.uk> - 2012-01-02 19:10 +0000
    Re: JavaScript's Character Escaping Functions Dr J R Stockton <reply1152@merlyn.demon.co.uk> - 2011-12-31 20:41 +0000

#9776 — JavaScript's Character Escaping Functions

FromGene Wirchenko <genew@ocis.net>
Date2011-12-29 17:30 -0800
SubjectJavaScript's Character Escaping Functions
Message-ID<nk4qf7ti2bbod0k5flbs0bbm880dpdvv35@4ax.com>
Dear JavaScripters:

     There are a number of functions for escaping various characters
and de-escaping them:
          Escape Function          Unescape Function
          ---------------          -----------------
          escape()                 unescape()
          encodeURI()              decodeURI()
          encodeURIComponent()     decodeURIComponent()
There may be others that I am unaware of.

     What I am definitely unaware of is when to use them.  I have not
seen any material on that other than vague (to me) sentences.  They
seem to assume that people already know what they are doing with them.

     Between them and HTML's "&something;", I really could use a good
grounding in the area.

     Pointers please?

Sincerely,

Gene Wirchenko

[toc] | [next] | [standalone]


#9778

FromTim Streater <timstreater@greenbee.net>
Date2011-12-30 10:33 +0000
Message-ID<timstreater-584CF1.10334730122011@news.individual.net>
In reply to#9776
In article <nk4qf7ti2bbod0k5flbs0bbm880dpdvv35@4ax.com>,
 Gene Wirchenko <genew@ocis.net> wrote:

> Dear JavaScripters:
> 
>      There are a number of functions for escaping various characters
> and de-escaping them:
>           Escape Function          Unescape Function
>           ---------------          -----------------
>           escape()                 unescape()
>           encodeURI()              decodeURI()
>           encodeURIComponent()     decodeURIComponent()
> There may be others that I am unaware of.
> 
>      What I am definitely unaware of is when to use them.  I have not
> seen any material on that other than vague (to me) sentences.  They
> seem to assume that people already know what they are doing with them.
> 
>      Between them and HTML's "&something;", I really could use a good
> grounding in the area.
> 
>      Pointers please?

<furtle, furtle>

Ah yes, here we are: pp 482-483 of JavaScript Bible 7th Edition seem to 
cover it.

What's that? You don't have any JavaScript books? Why not?

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#9803

FromGene Wirchenko <genew@ocis.net>
Date2011-12-30 11:45 -0800
Message-ID<in4sf7tqctga5bo3rhg7drg1tfbuc5v8od@4ax.com>
In reply to#9778
On Fri, 30 Dec 2011 10:33:47 +0000, Tim Streater
<timstreater@greenbee.net> wrote:

>In article <nk4qf7ti2bbod0k5flbs0bbm880dpdvv35@4ax.com>,
> Gene Wirchenko <genew@ocis.net> wrote:

[snip]

>>      Pointers please?
>
><furtle, furtle>
>
>Ah yes, here we are: pp 482-483 of JavaScript Bible 7th Edition seem to 
>cover it.
>
>What's that? You don't have any JavaScript books? Why not?

     I do have JavaScript books including one that is pretty good, but
it does not have all the detail I could wish for.  As for additional
books, well, I have already asked about that.  Take a look at the FAQ:

"3.1 What books are recommended for javascript?

Most javascript books have been found to contain so many technical
errors that consensus recommendations have not emerged from the group.

The following books have been considered to have value by some
individuals on c.l.js. The reviews of these books are provided:"

     There are links to discussion on the *two* titles, and said
discussions are not encouraging for a ptoential purchaser.

     If you have a better answer, how about submitting a change to FAQ
question 3.1?

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#9806

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2011-12-30 22:06 +0200
Message-ID<jdl5jv$uo7$1@dont-email.me>
In reply to#9803
2011-12-30 21:45, Gene Wirchenko wrote:

>       If you have a better answer, how about submitting a change to FAQ
> question 3.1?

Why would anyone submit a change proposal when there is no FAQ maintainer?

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

[toc] | [prev] | [next] | [standalone]


#9814

FromTim Streater <timstreater@greenbee.net>
Date2011-12-30 22:45 +0000
Message-ID<timstreater-798B0B.22450930122011@news.individual.net>
In reply to#9803
In article <in4sf7tqctga5bo3rhg7drg1tfbuc5v8od@4ax.com>,
 Gene Wirchenko <genew@ocis.net> wrote:

> On Fri, 30 Dec 2011 10:33:47 +0000, Tim Streater
> <timstreater@greenbee.net> wrote:
> 
> >In article <nk4qf7ti2bbod0k5flbs0bbm880dpdvv35@4ax.com>,
> > Gene Wirchenko <genew@ocis.net> wrote:
> 
> [snip]
> 
> >>      Pointers please?
> >
> ><furtle, furtle>
> >
> >Ah yes, here we are: pp 482-483 of JavaScript Bible 7th Edition seem to 
> >cover it.
> >
> >What's that? You don't have any JavaScript books? Why not?
> 
>      I do have JavaScript books including one that is pretty good, but
> it does not have all the detail I could wish for.  As for additional
> books, well, I have already asked about that.  Take a look at the FAQ:
> 
> "3.1 What books are recommended for javascript?
> 
> Most javascript books have been found to contain so many technical
> errors that consensus recommendations have not emerged from the group.
> 
> The following books have been considered to have value by some
> individuals on c.l.js. The reviews of these books are provided:"
> 
>      There are links to discussion on the *two* titles, and said
> discussions are not encouraging for a ptoential purchaser.
> 
>      If you have a better answer, how about submitting a change to FAQ
> question 3.1?

:-)

Well, I don't have a *better* answer, only my own opinion. See also my 
other post.

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#9805

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2011-12-30 12:03 -0800
Message-ID<e226276a-491d-4bca-be8f-5dc37c2d83a7@24g2000yqi.googlegroups.com>
In reply to#9776
On Dec 29, 7:30 pm, Gene Wirchenko <ge...@ocis.net> wrote:
> Dear JavaScripters:
>
>      There are a number of functions for escaping various characters
> and de-escaping them:
>           Escape Function          Unescape Function
>           ---------------          -----------------
>           escape()                 unescape()
>           encodeURI()              decodeURI()
>           encodeURIComponent()     decodeURIComponent()
> There may be others that I am unaware of.
>
>      What I am definitely unaware of is when to use them.  I have not
> seen any material on that other than vague (to me) sentences.  They
> seem to assume that people already know what they are doing with them.
>
>      Between them and HTML's "&something;", I really could use a good
> grounding in the area.
>
>      Pointers please?

You can look at MDN's documentation:

https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Functions#escape_and_unescape_Functions
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURI
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent

[toc] | [prev] | [next] | [standalone]


#9821

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2011-12-31 10:05 +0000
Message-ID<4efede55$0$30390$a8266bb1@newsreader.readnews.com>
In reply to#9776
On Thu, 29 Dec 2011 17:30:08 -0800, Gene Wirchenko wrote:

>      There are a number of functions for escaping various characters
> and de-escaping them:
> ....
>      Between them and HTML's "&something;", I really could use a good
> grounding in the area.

If I need to use any sort of character escaping, I tend to first work out 
exactly what I'm trying to escape and why, and then read the descriptions 
of each function to determine which one is best suited to my requirement.

Rgds

Denis McMahon

[toc] | [prev] | [next] | [standalone]


#9836

FromGene Wirchenko <genew@ocis.net>
Date2011-12-31 23:41 -0800
Message-ID<5f30g75q1h82jif9r1fcajc3gqffjvguhp@4ax.com>
In reply to#9821
On 31 Dec 2011 10:05:09 GMT, Denis McMahon <denismfmcmahon@gmail.com>
wrote:

>On Thu, 29 Dec 2011 17:30:08 -0800, Gene Wirchenko wrote:
>
>>      There are a number of functions for escaping various characters
>> and de-escaping them:
>> ....
>>      Between them and HTML's "&something;", I really could use a good
>> grounding in the area.
>
>If I need to use any sort of character escaping, I tend to first work out 
>exactly what I'm trying to escape and why, and then read the descriptions 
>of each function to determine which one is best suited to my requirement.

     Of course, it helps to know exactly what the functions are and
what they do.  Could that possibly be why I asked my question in the
first place?

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#9874

FromDr J R Stockton <reply1152@merlyn.demon.co.uk>
Date2012-01-02 19:10 +0000
Message-ID<jTMX9xELEgAPFwDV@invalid.uk.co.demon.merlyn.invalid>
In reply to#9836
In comp.lang.javascript message <5f30g75q1h82jif9r1fcajc3gqffjvguhp@4ax.
com>, Sat, 31 Dec 2011 23:41:26, Gene Wirchenko <genew@ocis.net> posted:

>     Of course, it helps to know exactly what the functions are and
>what they do.  Could that possibly be why I asked my question in the
>first place?

But the ECMA standard tells you exactly that.

-- 
 (c) John Stockton, nr London UK  ?@merlyn.demon.co.uk  IE8 FF8 Op11 Sf5 Cr15
   news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>.
   <http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
   <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

[toc] | [prev] | [next] | [standalone]


#9830

FromDr J R Stockton <reply1152@merlyn.demon.co.uk>
Date2011-12-31 20:41 +0000
Message-ID<Aw7vFYWoN3$OFwoQ@invalid.uk.co.demon.merlyn.invalid>
In reply to#9776
In comp.lang.javascript message <nk4qf7ti2bbod0k5flbs0bbm880dpdvv35@4ax.
com>, Thu, 29 Dec 2011 17:30:08, Gene Wirchenko <genew@ocis.net> posted:

>     There are a number of functions for escaping various characters
>and de-escaping them:
>          Escape Function          Unescape Function
>          ---------------          -----------------
>          escape()                 unescape()
>          encodeURI()              decodeURI()
>          encodeURIComponent()     decodeURIComponent()
>There may be others that I am unaware of.
>
>     What I am definitely unaware of is when to use them.  I have not
>seen any material on that other than vague (to me) sentences.  They
>seem to assume that people already know what they are doing with them.
>
>     Between them and HTML's "&something;", I really could use a good
>grounding in the area.
>
>     Pointers please?

ECMA 5.1 section 15.3 gives full detail for the URI ones.  The document
should be findable via the FAQ, and downloadable at an acceptable cost.
You need it.  Section B.2 explains the escapes.

I doubt whether you want any of them.

You probably want "Table 4 — String Single Character Escape Sequences"
in section 7.8.4.

You might also need section "7.8.5 Regular Expression Literals", and
section 15.10 if you don't know RegExps from other languages.

For the HTML, read Wikipedia "Character entity reference" and its links
including "List of XML and HTML character entity references".  For
characters outside that range, see <http://en.wikipedia.org/wiki/List_of
_Unicode_characters> and the definitive <http://unicode.org/charts/chari
ndex.html>.

If you discover that any of those cannot be found by links from pages on
my Web site, RSVP - should be in the js- and www- pages.

                If all else fails, read the manual.

-- 
 (c) John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v6.05   MIME.
   Web  <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
 Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
 Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web