What is WebDNA

WebDNA is a scripting and database system designed to easily build web applications.

WebDNA and BioType

BioType service is a biometric keystroke dynamic system. It will be part of WebDNA 8.5

Download WebDNA

Download WebDNA freeware, try it and register later if you want.

WebDNA resources

The list of all WebDNA instructions.
WebDNA
Software Corporation
Search WebDNA Site
 Menu


HOME


DOWNLOADS


LEARN


EDUCATION


NEWS


COMMUNITY


STORE


SUPPORT


CONTACT

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:

AOL and referrers on target=_blank (2000) IE-caching (1998) re:check boxes (1997) Multiple Pulldowns (1997) Webstar 1.3.1 PPC (1997) A question on sub-categories (1997) TCPconnect in a DB? (1999) Beta 3.0.3 fix for serial# problem (Mac) (1998) Bad Cookie / Internet Option / Internet Explorer (2004) WebCat2: Items xx to xx shown, etc. (1997) WebCatalog 2.0 & WebDNA docs in HTML ... (1997) [TaxableTotal] - not working with AOL and IE (1997) New Plug-in and Type 11 errors (1997) frames & carts (1997) carriage returns in data (1997) Setting up shop (1997) removing programming logic white space (2003) WebCat2b13 Command Reference Doc error (1997) can WC render sites out? (1997) WebDNA on Intel Mac (2006)