pureweb.util. stringUtil

The stringUtil namespace provides utility methods for working with strings.

Method Summary

arrayBufferToBase64
Converts an array of bytes into a base64 encoded string and returns that string.
base64ToArrayBuffer
Converts a base64 encoded string into an ArrayBuffer and returns that ArrayBuffer.
decodeUTF8
Converts an encoded UTF8 string into a decoded string.
decodeUTF8FromIntArray
Decodes the specified array of UTF-8 bytes into a string and returns that string.
encodeUTF8
Converts a byte string into a UTF8 encoded string.
encodeUTF8ToArrayBuffer
Encodes the specified string in UTF-8 and returns the encoded bytes.

Method Detail

<static> arrayBufferToBase64(raw, mimeType) → {string}

Converts an array of bytes into a base64 encoded string and returns that string.
Source: http://jsperf.com/encoding-xhr-image-data/6
Parameters:
Name Type Argument Description
raw ArrayBuffer The array bytes.
mimeType string <optional>
The mime type.

<static> base64ToArrayBuffer(base64) → {ArrayBuffer}

Converts a base64 encoded string into an ArrayBuffer and returns that ArrayBuffer.
Parameters:
Name Type Description
base64 string The base64 string.

<static> decodeUTF8(str) → {string}

Converts an encoded UTF8 string into a decoded string. Safe for use in browsers that don't support binary data.
Parameters:
Name Type Description
str string The encoded UTF8 string.
Deprecated:
  • This utility method will be removed in the next major PureWeb release, as this functionality is no required in the SDK.

    <static> decodeUTF8FromIntArray(bytes) → {string}

    Decodes the specified array of UTF-8 bytes into a string and returns that string.
    Parameters:
    Name Type Description
    bytes Uint8Array The array of UTF-8 bytes.

    <static> encodeUTF8(str) → {string}

    Converts a byte string into a UTF8 encoded string. Safe for use in browsers that don't support binary data.
    Parameters:
    Name Type Description
    str string The bytes string.
    Deprecated:
    • This utility method will be removed in the next major PureWeb release, as this functionality is no required in the SDK.

      <static> encodeUTF8ToArrayBuffer(str) → {ArrayBuffer}

      Encodes the specified string in UTF-8 and returns the encoded bytes.
      Parameters:
      Name Type Description
      str string The string to encode.