How to parse into base64 string the binary image from response?

后端 未结 6 1197
广开言路
广开言路 2020-11-30 02:49

I want to parse the requested image from my REST API into base64 string.

\"enter

6条回答
  •  野性不改
    2020-11-30 03:01

    Im guessing to use escape on the string before you pass it to the function, without the API call I can't test myself.

    test

    encodeURI("testñ$☺PNW¢=")
    

    returns

    "test%C3%B1$%E2%98%BAPNW%C2%A2="
    

    It just escapes all the characters, it should escape all the illegal characters in the string

    test

    encodeURI("¶!┼Æê‼_ðÄÄ┘Ì+\+,o▬MBc§yþó÷ö")
    

    returns

    "%C2%B6!%E2%94%BC%C3%86%C3%AA%E2%80%BC_%C3%B0%C3%84%C3%84%E2%94%98%C3%8C++,o%E2%96%ACMBc%C2%A7y%C3%BE%C3%B3%C3%B7%C3%B6"
    

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI

提交回复
热议问题