字符串编码 - Shift_JIS / UTF-8

String encoding - Shift_JIS / UTF-8

我从第 3 方库中得到一个字符串,该字符串编码不正确。 不幸的是,我不允许更改库或使用另一个库...

所以实际的问题是,第 3 方库结果字符串会将像“è ò à ù ì ä ö ü, ...”这样的字符编码为 UTF-8 中的 SHIFT_JIS(汉字)细绳。但前提是该字符与一个词相关并且不是独立的。

例如:

"Ö Just a simple test"

"ÖJust a simple test"

我尝试了以下但没有成功:

byte[] b = resultString.getBytes("Shift_JIS");
String value = new String(b, "UTF-8");

更新 1:

这就是"resultString"的内容。

注意: 显示的字节数组没有任何修改(例如 getBytes("Shift_JIS"),它只是作为字节的 resultString)

你有什么想法吗? 任何帮助将不胜感激。 谢谢。

嗯,很奇怪:

作为

byte[] b = resultString.getBytes("Shift_JIS");
String value = new String(b, "UTF-8");

对我不起作用我尝试了以下方法:

String value = new String(resultString.getBytes("SHIFT-JIS"), "UTF-8")

很有魅力。 可能是因为 "Shift_JIS".

中的下划线和小写字符