-
You are here: JS-methods > Documentation > Codecs

Codecs extensions

Extends string prototype with the following methods: decodeBase64, encodeBase64, decodeUTF8, encodeUTF8

This extensions doesn't depend on any other code or overwrite existing methods.

  • decodeBase64() : String
    Decodes a Base64 encoded string to a byte string.

    Example:

    "SmF2YVNjcmlwdA==".decode_base64();

    Result:

    "JavaScript"
  • decodeUTF8() : String
    Decodes a utf-8 encoded string back into multi-byte characters.

    Example:

    "http://www.delacap.com/products/?very%20nice".encode_uri();

    Result:

    "http://www.delacap.com/products/?very nice"
  • encodeBase64() : String
    Encodes a string using Base64.

    Example:

    "JavaScript==".encode_base64();

    Result:

    "SmF2YVNjcmlwdA=="
  • encodeUTF8() : String
    Encodes a multi-byte string into utf-8 multiple single-byte characters.

    Example:

    "http://www.delacap.com/products/?very%20nice".encode_uri();

    Result:

    "http://www.delacap.com/products/?very nice"