Base64 is used in cross platform transmission to ensure the integrity of non ASCII code strings
First, let's take an example:
In this case, the B and B1 byte arrays are the same.
What about the following situation?
The SS printed out is a pile of things we can't understand! And we found that the lengths of B and B1 byte arrays are different? Why?
We know that the ASCII encoding range is 0 ~ 127, so how to encode - 2 and - 9?
The bytes of B1 and B indicate that the data is distorted during transmission. How to solve the distortion problem?
We can use Base64 to modify the values of - 128 ~ 127 (please Google for details).
By encoding and decoding Base64, errors in the transmission process can be prevented. Base64 can use common codec, as shown below:
Method Summary
Note that in the process of URL transmission, in order to ensure no transmission errors (such as the lack of "+"), please try to use urlsafe method.