Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Base64编码btoa_Java_Angular_Encoding - Fatal编程技术网

Java Base64编码btoa

Java Base64编码btoa,java,angular,encoding,Java,Angular,Encoding,我正在使用btoa功能对前端部分的一些文本进行编码: const encodedText = btoa(searchText); 这似乎工作得很好,解码在后端部分是这样的: byte[] decodedBytes = Base64.getDecoder().decode(searchedText); String decodedString = new String(decodedBytes, Charset.defaultCharset()); 这也很好用。然而,当使用u字母时,这似乎失败

我正在使用btoa功能对前端部分的一些文本进行编码:

const encodedText = btoa(searchText);
这似乎工作得很好,解码在后端部分是这样的:

byte[] decodedBytes = Base64.getDecoder().decode(searchedText);
String decodedString = new String(decodedBytes, Charset.defaultCharset());
这也很好用。然而,当使用u字母时,这似乎失败了。我的程序将其编码为A==,据我所知,它应该是w7w=

我不确定我做错了什么。

你可以用

const encodedText = btoa(unescape(encodeURIComponent(searchText)));
而是先对unicode字符进行编码

有关详细信息,请参阅和

console.log(btoa('u'));

log(btoa(unescape(encodeURIComponent('u')))