Ho un sacco di caratteri con che sembra qualcosa di simile:Java convertire flusso di caratteri in umana String "leggibile"
Комуникационна кабелна система
ea volte ho un mix come questo:
Généralités
Il prima si traduce in:
К о м у н и к а ц и о н н а к а б е л н а с и с т е м а
e il secondo a:
G é n é ralit é s
posso vedere questo utilizzando un browser e metterli nel corpo.
Ma come posso rendere java i caratteri "reali"? Come si chiama la codifica sopra?
Ho provato un paio di cose, e, infine, questo (che non ha funzionato):
import java.nio.charset.*;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
List<String> lst = new ArrayList<String>(); lst.add("К"); lst.add("о");
for (String s : lst) {
Charset utf8charset = Charset.forName("UTF-8");
Charset iso88591charset = Charset.forName("ISO-8859-1");
ByteBuffer inputBuffer = ByteBuffer.wrap(s.getBytes());
// decode UTF-8
CharBuffer data = utf8charset.decode(inputBuffer);
// encode ISO-8559-1
ByteBuffer outputBuffer = iso88591charset.encode(data);
byte[] outputData = outputBuffer.array();
System.out.println (new String(outputData))
}
È in formato HTML. –
quelli sono chiamati entità. se cerchi la conversione da entità ad Unicode puoi trovare quello che stai cercando in quel modo – dldnh
@dldnh grazie per aver chiarito! non è la cosa più facile da cercare sul web :) – momomo