Skip to content

Commit 577ceb2

Browse files
committed
#1386 PMD is changing encoding of source code
1 parent 530f675 commit 577ceb2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Eclipse Update Site: <https://sourceforge.net/projects/pmd/files/pmd-eclipse/upd
99
* Updated PMD to 5.3.5
1010
* Fixed PMD-Plugin does not work if run with IBM JDK 1.7.0 ([bug #1419](https://sourceforge.net/p/pmd/bugs/1419/))
1111
* Fixed PMD Eclipse is not executed if "Full build" is not enabled ([bug #1435](https://sourceforge.net/p/pmd/bugs/1435/))
12+
* Fixed PMD is changing encoding of source code ([bug #1386](https://sourceforge.net/p/pmd/bugs/1386/))
1213

1314
**API Changes**:
1415

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/actions/ReviewAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected void insertReview(IMarker marker, boolean reviewPmdStyle) {
123123

124124
monitorWorked();
125125

126-
file.setContents(new ByteArrayInputStream(sourceCode.getBytes()), false, true, getMonitor());
126+
file.setContents(new ByteArrayInputStream(sourceCode.getBytes(file.getCharset())), false, true, getMonitor());
127127

128128
monitorWorked();
129129
} else {
@@ -287,7 +287,8 @@ private static String computeIndent(String sourceCode, int offset) {
287287

288288
public static String readFile(IFile file) throws IOException, CoreException {
289289
InputStream contents = file.getContents(true);
290-
InputStreamReader reader = new InputStreamReader(contents);
290+
String charset = file.getCharset();
291+
InputStreamReader reader = new InputStreamReader(contents, charset);
291292

292293
try {
293294
char[] buffer = new char[4096];

0 commit comments

Comments
 (0)