# HG changeset patch # User Yaroslav Zhuravlev # Date 1658245990 -3600 # Node ID b4eb565bbb1ff1a3504fc4094d78781bb82725a4 # Parent 1e1a15c845151d274322ead26c31c261a5b8aecd Documented atob and btoa global functions in njs. diff -r 1e1a15c84515 -r b4eb565bbb1f xml/en/docs/njs/reference.xml --- a/xml/en/docs/njs/reference.xml Tue Jul 19 16:53:00 2022 +0100 +++ b/xml/en/docs/njs/reference.xml Tue Jul 19 16:53:10 2022 +0100 @@ -9,7 +9,7 @@
+ rev="84">
@@ -2591,6 +2591,58 @@ +
+ + + + +atob(encodedData) + +Decodes a string of data which has been encoded +using Base64 encoding. +The encodedData parameter is a binary string +that contains Base64-encoded data. +Returns a string that contains decoded data from encodedData. + +The similar btoa() method +can be used to encode and transmit data +which may otherwise cause communication problems, +then transmit it and use the atob() method +to decode the data again. +For example, you can encode, transmit, and decode control characters +such as ASCII values 0 through 31. + +const encodedData = btoa("text to encode"); // encode a string +const decodedData = atob(encodedData); // decode the string + + + + +btoa(stringToEncode) + +Creates a Base64-encoded ASCII string from a binary string. +The stringToEncode parameter is a binary string to encode. +Returns an ASCII string containing the Base64 representation of +stringToEncode. + +The method can be used to encode data +which may otherwise cause communication problems, transmit it, +then use the atob() method +to decode the data again. +For example, you can encode control characters +such as ASCII values 0 through 31. + +const encodedData = btoa("text to encode"); // encode a string +const decodedData = atob(encodedData); // decode the string + + + + + + + +
+