Re: [WebDNA] Escaping content for JSON

This WebDNA talk-list message is from

2016


It keeps the original formatting.
numero = 113232
interpreted = N
texte = 820 --Apple-Mail=_8AC1B9C6-46C4-4D78-B6A6-F1327C9133AF Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Nice Tom. Thanks for sharing :) Kind regards Stuart Tremain Pharoah Lane Software AUSTRALIA webdna@idfk.com.au > On 28 Nov. 2016, at 08:04, Tom Duke wrote: >=20 > Hi all, >=20 > Re-visting this as I am doing a lot of work involving JSON and = Javascript and escaping strings was doing my head in. >=20 > These functions work and only require one [convertchars] pass. Thanks = to the write up by Brian and Terry here - = http://www.webdna.us/page.dna?numero=3D183 = - which outlined that both = the from, and to fields are first [unurl]'d when using convert chars. >=20 > It might help someone else. >=20 > - Tom >=20 >=20 >=20 > Ref:=20 > = http://stackoverflow.com/questions/983451/where-can-i-find-a-list-of-escap= e-characters-required-for-my-json-ajax-return-tyd = > https://en.wikipedia.org/wiki/UTF-8#Codepage_layout = >=20 >=20 >=20 > [function name=3Djson_escape][!] >=20 > Note Char Hex Stored in WebDNA As > Quote " %22 " > BackSlash \ %5C \ > ForwardSlash / / / > Form Feed %08 %08 > Line Feed %0A %0B > Carriage Return %0D %0B > Horizontal Tab %09 %1D >=20 > %0B and %1D added to convert data read from a WebDNA db >=20 > [/!][table name=3DtabJSONESCAPE&fields=3Dfrom,to] > %22\%22 > %5C\%5C > /\/ > %08\b > %0C\f > %0A\n > %0D\r > %09\t > %0B\n > %1D\t > [/table][!] > [/!][return][convertchars = table=3DtabJSONESCAPE][params_string][/convertchars][/return][!] > [/!][/function] >=20 > [text]test_string=3DL "John" & \ / Joanna ' + Jane[/text] >=20 > [json_escape [test_string]] >=20 > Result: L \"John\" & \\ \/ Joanna ' + Jane >=20 >=20 >=20 > [function name=3Djs_escape][!] >=20 > Note Char Hex Stored in WebDNA As > Quote " %22 " > Apostraphe ' %27 ' > BackSlash \ %5C \ > ForwardSlash / / / > Form Feed %08 %08 > Line Feed %0A %0B > Carriage Return %0D %0B > Horizontal Tab %09 %1D >=20 > %0B and %1D added to convert data read from a WebDNA db >=20 > [/!][table name=3DtabJSESCAPE&fields=3Dfrom,to] > %22\%22 > %27\%27 > %5C\%5C > /\/ > %08\b > %0C\f > %0A\n > %0D\r > %09\t > %0B\n > %1D\t > [/table][!] > [/!][return][convertchars = table=3DtabJSESCAPE][params_string][/convertchars][/return][!] > [/!][/function] >=20 > [text]test_string=3DL "John" & \ / Joanna ' + Jane[/text] >=20 > [js_escape [test_string]] >=20 > Result: L \"John\" & \\ \/ Joanna \' + Jane >=20 >=20 > --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list . To = unsubscribe, E-mail to: archives: = http://mail.webdna.us/list/talk@webdna.us Bug Reporting: = support@webdna.us --Apple-Mail=_8AC1B9C6-46C4-4D78-B6A6-F1327C9133AF Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Nice Tom.

Thanks for sharing :)


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA






On 28 Nov. 2016, at 08:04, Tom Duke <tom@revolutionaries.ie> wrote:

Hi all,

Re-visting this as I am doing a lot of work = involving JSON and Javascript and escaping strings was doing my head = in.

These functions work and only require one = [convertchars] pass.  Thanks to the write up by Brian and Terry = here - http://www.webdna.us/page.dna?numero=3D183 - which = outlined that both the from, and to fields are first [unurl]'d when = using convert chars.

It might help someone = else.

- Tom



Ref: 
http://stackoverflow.com/questions/983451/where-can-i-find-a-li= st-of-escape-characters-required-for-my-json-ajax-return-tyd
=



[function name=3Djson_escape][!]

= Note            Char     = Hex     Stored in WebDNA As
= Quote           "       =  %22     "
= BackSlash       \        %5C =     \
= ForwardSlash    /        /   =     /
= Form Feed               =  %08     %08
= Line Feed               =  %0A     %0B
= Carriage Return          %0D   =   %0B
Horizontal Tab     =       %09     %1D

= %0B and %1D added to convert data read from a WebDNA db

[/!][table = name=3DtabJSONESCAPE&fields=3Dfrom,to]
%22\%22
%5C\%5C
/\/
%08\b
%0C\f
%0A\n
%0D\r
%09\t
%0B\n
%1D\t
[/table][!]
= [/!][return][convertchars = table=3DtabJSONESCAPE][params_string][/convertchars][/return][!]
[/!][/function]

[text]test_string=3DL "John" & \  / Joanna ' + = Jane[/text]

[json_escape [test_string]]

Result: L \"John\" & \\ \/ = Joanna ' + Jane



[function name=3Djs_escape][!]

= Note            Char     = Hex     Stored in WebDNA As
= Quote           "       =  %22     "
= Apostraphe      '       =             %27   =   '
= BackSlash       \        %5C =     \
= ForwardSlash    /        /   =     /
= Form Feed               =  %08     %08
= Line Feed               =  %0A     %0B
= Carriage Return          %0D   =   %0B
Horizontal Tab     =       %09     %1D

= %0B and %1D added to convert data read from a WebDNA db

[/!][table = name=3DtabJSESCAPE&fields=3Dfrom,to]
%22\%22
%27\%27
%5C\%5C
/\/
%08\b
%0C\f
%0A\n
%0D\r
%09\t
%0B\n
%1D\t
[/table][!]
= [/!][return][convertchars = table=3DtabJSESCAPE][params_string][/convertchars][/return][!]
[/!][/function]

[text]test_string=3DL "John" & \  / Joanna ' + = Jane[/text]

[js_escape [test_string]]

Result: L \"John\" & \\ \/ = Joanna \' + Jane


--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us

= --------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us --Apple-Mail=_8AC1B9C6-46C4-4D78-B6A6-F1327C9133AF-- . Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] Escaping content for JSON (Stuart Tremain 2016)
  2. Re: [WebDNA] Escaping content for JSON (Tom Duke 2016)
  3. Re: [WebDNA] Escaping content for JSON (Tom Duke 2013)
  4. Re: [WebDNA] Escaping content for JSON (Donovan Brooke 2013)
  5. [WebDNA] Escaping content for JSON (Tom Duke 2013)
820 --Apple-Mail=_8AC1B9C6-46C4-4D78-B6A6-F1327C9133AF Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Nice Tom. Thanks for sharing :) Kind regards Stuart Tremain Pharoah Lane Software AUSTRALIA webdna@idfk.com.au > On 28 Nov. 2016, at 08:04, Tom Duke wrote: >=20 > Hi all, >=20 > Re-visting this as I am doing a lot of work involving JSON and = Javascript and escaping strings was doing my head in. >=20 > These functions work and only require one [convertchars] pass. Thanks = to the write up by Brian and Terry here - = http://www.webdna.us/page.dna?numero=3D183 = - which outlined that both = the from, and to fields are first [unurl]'d when using convert chars. >=20 > It might help someone else. >=20 > - Tom >=20 >=20 >=20 > Ref:=20 > = http://stackoverflow.com/questions/983451/where-can-i-find-a-list-of-escap= e-characters-required-for-my-json-ajax-return-tyd = > https://en.wikipedia.org/wiki/UTF-8#Codepage_layout = >=20 >=20 >=20 > [function name=3Djson_escape][!] >=20 > Note Char Hex Stored in WebDNA As > Quote " %22 " > BackSlash \ %5C \ > ForwardSlash / / / > Form Feed %08 %08 > Line Feed %0A %0B > Carriage Return %0D %0B > Horizontal Tab %09 %1D >=20 > %0B and %1D added to convert data read from a WebDNA db >=20 > [/!][table name=3DtabJSONESCAPE&fields=3Dfrom,to] > %22\%22 > %5C\%5C > /\/ > %08\b > %0C\f > %0A\n > %0D\r > %09\t > %0B\n > %1D\t > [/table][!] > [/!][return][convertchars = table=3DtabJSONESCAPE][params_string][/convertchars][/return][!] > [/!][/function] >=20 > [text]test_string=3DL "John" & \ / Joanna ' + Jane[/text] >=20 > [json_escape [test_string]] >=20 > Result: L \"John\" & \\ \/ Joanna ' + Jane >=20 >=20 >=20 > [function name=3Djs_escape][!] >=20 > Note Char Hex Stored in WebDNA As > Quote " %22 " > Apostraphe ' %27 ' > BackSlash \ %5C \ > ForwardSlash / / / > Form Feed %08 %08 > Line Feed %0A %0B > Carriage Return %0D %0B > Horizontal Tab %09 %1D >=20 > %0B and %1D added to convert data read from a WebDNA db >=20 > [/!][table name=3DtabJSESCAPE&fields=3Dfrom,to] > %22\%22 > %27\%27 > %5C\%5C > /\/ > %08\b > %0C\f > %0A\n > %0D\r > %09\t > %0B\n > %1D\t > [/table][!] > [/!][return][convertchars = table=3DtabJSESCAPE][params_string][/convertchars][/return][!] > [/!][/function] >=20 > [text]test_string=3DL "John" & \ / Joanna ' + Jane[/text] >=20 > [js_escape [test_string]] >=20 > Result: L \"John\" & \\ \/ Joanna \' + Jane >=20 >=20 > --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list . To = unsubscribe, E-mail to: archives: = http://mail.webdna.us/list/talk@webdna.us Bug Reporting: = support@webdna.us --Apple-Mail=_8AC1B9C6-46C4-4D78-B6A6-F1327C9133AF Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Nice Tom.

Thanks for sharing :)


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA






On 28 Nov. 2016, at 08:04, Tom Duke <tom@revolutionaries.ie> wrote:

Hi all,

Re-visting this as I am doing a lot of work = involving JSON and Javascript and escaping strings was doing my head = in.

These functions work and only require one = [convertchars] pass.  Thanks to the write up by Brian and Terry = here - http://www.webdna.us/page.dna?numero=3D183 - which = outlined that both the from, and to fields are first [unurl]'d when = using convert chars.

It might help someone = else.

- Tom



Ref: 
http://stackoverflow.com/questions/983451/where-can-i-find-a-li= st-of-escape-characters-required-for-my-json-ajax-return-tyd
=



[function name=3Djson_escape][!]

= Note            Char     = Hex     Stored in WebDNA As
= Quote           "       =  %22     "
= BackSlash       \        %5C =     \
= ForwardSlash    /        /   =     /
= Form Feed               =  %08     %08
= Line Feed               =  %0A     %0B
= Carriage Return          %0D   =   %0B
Horizontal Tab     =       %09     %1D

= %0B and %1D added to convert data read from a WebDNA db

[/!][table = name=3DtabJSONESCAPE&fields=3Dfrom,to]
%22\%22
%5C\%5C
/\/
%08\b
%0C\f
%0A\n
%0D\r
%09\t
%0B\n
%1D\t
[/table][!]
= [/!][return][convertchars = table=3DtabJSONESCAPE][params_string][/convertchars][/return][!]
[/!][/function]

[text]test_string=3DL "John" & \  / Joanna ' + = Jane[/text]

[json_escape [test_string]]

Result: L \"John\" & \\ \/ = Joanna ' + Jane



[function name=3Djs_escape][!]

= Note            Char     = Hex     Stored in WebDNA As
= Quote           "       =  %22     "
= Apostraphe      '       =             %27   =   '
= BackSlash       \        %5C =     \
= ForwardSlash    /        /   =     /
= Form Feed               =  %08     %08
= Line Feed               =  %0A     %0B
= Carriage Return          %0D   =   %0B
Horizontal Tab     =       %09     %1D

= %0B and %1D added to convert data read from a WebDNA db

[/!][table = name=3DtabJSESCAPE&fields=3Dfrom,to]
%22\%22
%27\%27
%5C\%5C
/\/
%08\b
%0C\f
%0A\n
%0D\r
%09\t
%0B\n
%1D\t
[/table][!]
= [/!][return][convertchars = table=3DtabJSESCAPE][params_string][/convertchars][/return][!]
[/!][/function]

[text]test_string=3DL "John" & \  / Joanna ' + = Jane[/text]

[js_escape [test_string]]

Result: L \"John\" & \\ \/ = Joanna \' + Jane


--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us

= --------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us --Apple-Mail=_8AC1B9C6-46C4-4D78-B6A6-F1327C9133AF-- . Stuart Tremain

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

WebCatalog can't find database (1997) Ooops..Broswer Info.txt (was Web*SSL and WebCatalog) (1997) emailer (1997) WebCat2b13MacPlugin - nested [xxx] contexts (1997) Help name our technology! I found it (1997) totals (1997) Exclamation point (1997) POS (2000) Missing from Docs [folderName] (1997) This list needs a digest: rant, rave... (1997) popups, netscape vs explorer (1997) Country & Ship-to address & other fields ? (1997) message forum question (2005) PDF mailing labels (2000) Cold Fusion Warm and Fuzzy? (1999) BUG REPORT -- FINAL (1999) MacAuthorize and WebMerchant (1997) several .hdr files with one db file? (1999) [WebDNA] Timer (2008) WebCatalog f2 Installation (1997)