Hi Kamidu,
Have we tried "escape" and "unescape" described on the same article?

Cheers,


On Wed, Feb 24, 2016 at 11:44 AM, Kamidu Punchihewa <[email protected]>
wrote:

> Hi Dakshitha/Jerad,
>
> Any thoughts on the above situation ?
>
> Thanks and Regards.
> Kamidu Sachith Punchihewa
> *Software Engineer*
> WSO2, Inc.
> lean . enterprise . middleware
> Mobile : +94 (0) 770566749 <%2B94%20%280%29%20773%20451194>
>
>
> Disclaimer: This communication may contain privileged or other
> confidential information and is intended exclusively for the addressee/s.
> If you are not the intended recipient/s, or believe that you may have
> received this communication in error, please reply to the sender indicating
> that fact and delete the copy you received and in addition, you should not
> print, copy, retransmit, disseminate, or otherwise use the information
> contained in this communication. Internet communications cannot be
> guaranteed to be timely, secure, error or virus-free. The sender does not
> accept liability for any errors or omissions.
>
> ---------- Forwarded message ----------
> From: Kamidu Punchihewa <[email protected]>
> Date: Mon, Feb 15, 2016 at 11:40 AM
> Subject: [Dev][Encoding Special Charactors] Throws an Character Out Of
> Range exception
> To: WSO2 Developers' List <[email protected]>
>
>
> Hi All,
>
> When Encoding String including special / Latin characters throws an
> Character Out Of Range exception when we use *encodeURIComponent and
> decodeURIComponent* methods which was recommended to used behalf of  *escape
> and unescape* since there are deprecated.
> Using *escape and unescape* does not cause the above issues and Mozilla
> Developer Network Publication[1] still encourage to use *escape and
> unescape *alone with the *encodeURIComponent and decodeURIComponent. *
>
> Recommended Approach is given below.
>
> function utf8_to_b64(str) {
>     return window.btoa(escape(encodeURIComponent(str)));}
> function b64_to_utf8(str) {
>     return decodeURIComponent(unescape(window.atob(str)));}
>
>
> If we replace *escape and unescape with **encodeURIComponent and
> decodeURIComponent *the functions seems recursive as given below.
>
> function utf8_to_b64(str) {
>     return window.btoa(encodeURIComponent(encodeURIComponent(str)));
> }
> function b64_to_utf8(str) {
>     return decodeURIComponent(decodeURIComponent(window.atob(str)));
> }
>
> Which is the most appropriate way of utilising the above function?
>
> [1].https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/btoa
>
> Thanks & Best Regards.
> Kamidu Sachith Punchihewa
> *Software Engineer*
> WSO2, Inc.
> lean . enterprise . middleware
> Mobile : +94 (0) 770566749 <%2B94%20%280%29%20773%20451194>
>
>
> Disclaimer: This communication may contain privileged or other
> confidential information and is intended exclusively for the addressee/s.
> If you are not the intended recipient/s, or believe that you may have
> received this communication in error, please reply to the sender indicating
> that fact and delete the copy you received and in addition, you should not
> print, copy, retransmit, disseminate, or otherwise use the information
> contained in this communication. Internet communications cannot be
> guaranteed to be timely, secure, error or virus-free. The sender does not
> accept liability for any errors or omissions.
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 

*Ruwan Abeykoon*
*Architect,*
*WSO2, Inc. http://wso2.com <http://wso2.com/> *
*lean.enterprise.middleware.*

email: [email protected]
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to