如何将包含OCTL字符的字符串转换为ISO-8859-15,使其不稳定.我和java一起工作。泰。
我试图恢复informix的值,我把它放进字符串中,但是当我看到ESPA\321A-->我想看ESPA A的时候,我正在寻找一把锯子\321是一个OCTL,这可能吗?
HTML OCTL HEX CMP CHR含义
\321 =D1 \\x=D_1\x{e 010}\\x{e76f}\321=d1\x{e 010}\\x{e76f}\\x{e76f}\x1=d1\x{e 010} N ~溶胶-(N)
因此,OCTL = \321 =
我试过了,但别为我工作,我做错了什么。
Charset charset = Charset.forName("OCTL");
CharsetDecoder decoder = charset.newDecoder();
CharsetEncoder encoder = charset.newEncoder();
try {
ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(rs.getString(Constants.DES_PAIS_COM)));
ByteBuffer and then to a string.
CharBuffer cbuf = decoder.decode(bbuf);
String s = cbuf.toString();
deuteDetall.setDesPaisCom(s);
} catch (CharacterCodingException e) {
}发布于 2013-09-26 11:19:04
\321是八进制,以十六进制表示,(3*64+2*8+1)。
String s = "...";
Pattern OCTAL = Pattern.compile("\\\\(\\d\\d\\d)");
StringBuffer sb = new StringBuffer();
byte[] b1 = new byte[1];
Matcher m = OCTAL.matcher(s);
while (m.find()) {
String replacement = m.group(): // default original
try {
b1[0] = (byte)Integer.parseInt(m.group(1), 8);
replacement = new String(b1, "ISO-8859-15");
} catch (NumberFormatException e) {
//...
}
m.appendReplacement(sb, replacement);
}
m.appendTail(sb);
s = sb.toString();https://stackoverflow.com/questions/19026422
复制相似问题