Skip to content

Commit 5817fc4

Browse files
wahlbrinklaeubi
authored andcommitted
Fix encoding for 'compare with clipboard' if default encoding is not
UTF-8
1 parent 2cd05a8 commit 5817fc4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ClipboardCompare.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.eclipse.compare.CompareConfiguration;
2323
import org.eclipse.compare.CompareEditorInput;
2424
import org.eclipse.compare.CompareUI;
25-
import org.eclipse.compare.IStreamContentAccessor;
25+
import org.eclipse.compare.IEncodedStreamContentAccessor;
2626
import org.eclipse.compare.ITypedElement;
2727
import org.eclipse.compare.structuremergeviewer.DiffNode;
2828
import org.eclipse.core.resources.IFile;
@@ -125,7 +125,7 @@ private void processComparison(IFile file, Shell parentShell) throws IOException
125125
* @param parentShell The shell containing this window's controls
126126
*/
127127
private void showComparison(String source, String fileName, String clipboardContents, Shell parentShell) {
128-
class ClipboardTypedElement implements ITypedElement, IStreamContentAccessor {
128+
class ClipboardTypedElement implements ITypedElement, IEncodedStreamContentAccessor {
129129
private final String name;
130130
private final String content;
131131

@@ -149,6 +149,11 @@ public String getType() {
149149
return null;
150150
}
151151

152+
@Override
153+
public String getCharset() throws CoreException {
154+
return "UTF-8"; //$NON-NLS-1$
155+
}
156+
152157
@Override
153158
public InputStream getContents() throws CoreException {
154159
return new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));

0 commit comments

Comments
 (0)