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:

SSL do I need it?? (1998) when is date system date or order date? (1997) Urgent help needed (1998) WebCatalog 4.0 has been released! (2000) [protect admin] (1997) Deleting Orders (1997) View a Order file (1999) Now when I send TeaRoom Order fields it does not post in Invoice. (1997) Triggers and inventory... (2003) GuestBook example (1997) Comments in db? (1997) Showif, Hideif reverse logic ? (1997) Variable prices and Formulas.db (1997) [referrer] tag (1997) Dubble Sku's in a Database (1999) Robert Minor duplicate mail (1997) [sendmail] questions... (1997) embedding commands in form (1999) PSC recommends what date format yr 2000??? (1997) Re1000001: Setting up shop (1997)