UNPKG

cv-dialog-sdk

Version:

Catavolt Dialog Javascript API

26 lines (25 loc) 836 B
/* tslint:disable */ /* This implementation expects javascript strings (UTF-16) but operates on UTF-8 chars It will break if given characters out of range. Use another method to encodeString binary data directly (i.e. ArrayBuffer) https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings/30106551 */ export class Base64 { static encodeString(str) { return btoa(str); } static encodeUrlSafeString(str) { str = btoa(str); str = str.replace('+', '-'); str = str.replace('/', '_'); return str; } static decodeString(str) { return atob(str); } static decodeUrlSafeString(str) { str = str.replace('-', '+'); str = str.replace('_', '/'); return atob(str); } }