Java – how to encode a string to replace all special characters
I have a string containing special characters But I have to convert a string to a string without any special characters, so I use Base64, but in Base64 we use the equals sign (=), which is a special character But I want to convert a string to a string with only alphanumeric characters In addition, I can't delete special characters. I just need to replace all special characters to maintain the uniqueness between two different strings How do I achieve this and what kind of coding will help me achieve this goal?
Solution
The simplest choice is to use UTF-8 to encode the text into binary, and then convert the binary file into text into hexadecimal (two characters per byte) It won't be very effective, but it's just alphanumeric
You can use base32 to improve efficiency, but this may significantly increase the workload unless you can find a library to support it (libraries that perform hexadecimal encoding are very common.)