Java 7에서는 "Windows-1252"라는 텍스트를 가져오고 Windows Latin-1입니다.
Path oldPath = Paths.get("C:/Temp/old.txt");
Path newPath = Paths.get("C:/Temp/new.txt");
byte[] bytes = Files.readAllBytes(oldPath);
String content = "\uFEFF" + new String(bytes, "Windows-1252");
bytes = content.getBytes("UTF-8");
Files.write(newPath, bytes, StandardOption.WRITE);
바이트를 사용하여이를 Windows Latin-1로 해석합니다. 그리고 NotePad에 대한 트릭 : NotePad는 선행 BOM 마커 문자로 인코딩을 인식합니다. UTF-8에서는 일반적으로 사용되지 않는 너비가없는 공간입니다.
그런 다음 String에서 UTF-8 인코딩을 사용합니다.
Windows-1252는 ISO-8859-1 (순수한 라틴어 -1)이지만 0x80 - 0xBF 범위의 쉼표 따옴표와 같은 일부 특수 문자가 있습니다. 자바 6에서
:
File oldPath = new File("C:/Temp/old.txt");
File newPath = new File("C:/Temp/new.txt");
long longLength = oldPath.length();
if (longLength > Integer.MAX_VALUE) {
throw new IllegalArgumentException("File too large: " + oldPath.getPath());
}
int fileSize = (int)longLength;
byte[] bytes = new byte[fileSize];
InputStream in = new FileInputStream(oldPath);
int nread = in.read(bytes);
in.close();
assert nread == fileSize;
String content = "\uFEFF" + new String(bytes, "Windows-1252");
bytes = content.getBytes("UTF-8");
OutputStream out = new FileOutputStream(newPath);
out.write(bytes);
out.close();
독일어 웹 사이트는 종종 ISO-8859-1 또는 -15로 인코딩됩니다. 클립 보드를 통해 이동하면 문자가 현재 OS의 현재 인코딩 스타일로 변환됩니다. – reporter
예, iso-8859-1이 아마도 도움이 될 것입니다. – AKDADEVIL