UTF-8 转 UNIcode

来源:互联网 发布:打印机正在接收数据 编辑:程序博客网 时间:2024/06/06 07:37
针对中文显示乱码
private String encodeQuotedPrintable(final String str) {    if (TextUtils.isEmpty(str)) {        return "";    }    final StringBuilder builder = new StringBuilder();    int index = 0;    int lineCount = 0;    byte[] strArray = null;    try {        strArray = str.getBytes("UTF-8");    } catch (UnsupportedEncodingException e) {        strArray = str.getBytes();    }    while (index < strArray.length) {        builder.append(String.format("=%02X", strArray[index]));        index += 1;        lineCount += 3;        if (lineCount >= 67) {            // Specification requires CRLF must be inserted before the            // length of the line            // becomes more than 76.            // Assuming that the next character is a multi-byte character,            // it will become            // 6 bytes.            // 76 - 6 - 3 = 67            builder.append("=\r\n");            lineCount = 0;        }    }    return builder.toString();}

                                             
0 0
原创粉丝点击