How to parse into base64 string the binary image from response?
问题 I want to parse the requested image from my REST API into base64 string. Firstly... I thought, it would be easy, just to use window.btoa() function for this aim. When I try to do it in such part of my application: .done( function( response, position ) { var texture = new Image(); texture.src = \"data:image/png;base64,\" + window.btoa( response ); I\'ve got the next error: Uncaught InvalidCharacterError: Failed to execute \'btoa\' on \'Window\': The string to be encoded contains characters