public String convertCharset(String s) {  
        if (s != null) {  
            try {  
                int length = s.length();  
                byte[] buffer = new byte[length];  
                // 0x81 to Unicode 0x0081, 0x8d to 0x008d, 0x8f to 0x008f, 0x90  
                // to 0x0090, and 0x9d to 0x009d.  
                for (int i = 0; i < length; ++i) {  
                    char c = s.charAt(i);  
                    if (c == 0x0081) {  
                        buffer[i] = (byte) 0x81;  
                    } else if (c == 0x008d) {  
                        buffer[i] = (byte) 0x8d;  
                    } else if (c == 0x008f) {  
                        buffer[i] = (byte) 0x8f;  
                    } else if (c == 0x0090) {  
                        buffer[i] = (byte) 0x90;  
                    } else if (c == 0x009d) {  
                        buffer[i] = (byte) 0x9d;  
                    } else {  
                        buffer[i] = Character.toString(c).getBytes("CP1252")[0];  
                    }  
                }  
                String result = new String(buffer, "UTF-8");  
                return result;  
            } catch (UnsupportedEncodingException e) {  
                e.printStackTrace();  
            }  
        }  
        return null;  
    }  

 

相关文章:

  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-09-14
  • 2022-02-10
猜你喜欢
  • 2022-01-08
  • 2021-06-24
  • 2022-12-23
  • 2022-03-09
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案