The problem of transcoding between iso8859-1 and GBK

probably think of it this way, adding a new intermediate pre-forward to the original. But the data is not right after transcoding.
after performing a series of operations on a string of data, it is roughly as follows

        (1)---------------
        String pwdString = new String(byteUtf8,"ISO8859-1");
        (2)---------------
        byte[] gg = pwdString.getBytes("GBK");
        (3)---------------
        String ggg = new String(gg,"GBK");
        (4)---------------
        String s4 = new String(ggg.getBytes("GBK"),"ISO8859-1");
        
        :7D2513D2BF374287
        
        :7D25133F3F37423F
       

ISO8859-1 seems to have lost data after being transferred to GBK. However, if there is no problem with the UTF-8 used in the interaction between the two steps, and then go back to the original data, it is the same as follows

        (1)---------------
        String pwdString = new String(byteUtf8,"ISO8859-1");
        (2)---------------
        byte[] gg = pwdString.getBytes("UTF-8");
        (3)---------------
        String ggg = new String(gg,"UTF-8");
        (4)---------------
        String s4 = new String(ggg.getBytes("ISO8859-1"),"ISO8859-1");
        
        :7D2513D2BF374287
        
        :7D2513D2BF374287
Mar.28,2021

looks like the first few bits are right, and then there are problems with the last few bits. It is estimated that some coding requirements are followed by 0 to ensure that the final total length is a multiple of 8. You can try it in this direction, without writing code, just try it with some online transcoding tools.

Menu