Encoding can be defined in many places. It could be defined for a specific resource, workspace, JVM invocation or platform. Let Eclipse handle the logic. We always ask for the current revisions encoding, which in theory could be different from the encoding specified for the version we are retrieving. Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> --- .../egit/ui/internal/decorators/GitDocument.java | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java index a985a68..a9c0c7d 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java @@ -9,8 +9,10 @@ import java.io.IOException; +import org.eclipse.core.resources.IEncodedStorage; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.text.Document; import org.eclipse.team.core.RepositoryProvider; import org.spearce.egit.core.GitProvider; @@ -66,7 +68,23 @@ void populate() throws IOException { Activator.trace("(GitQuickDiffProvider) compareTo: " + baseline); ObjectLoader loader = repository.openBlob(blobEnry.getId()); byte[] bytes = loader.getBytes(); - String s = new String(bytes); // FIXME Platform default charset. should be Eclipse default + String charset; + // Get the encoding for the current version. As a matter of + // principle one might want to use the eclipse settings for the + // version we are retrieving as that may be defined by the + // project settings, but there is no historic API for this. + IEncodedStorage encodedStorage = ((IEncodedStorage)resource); + try { + if (encodedStorage != null) + charset = encodedStorage.getCharset(); + else + charset = resource.getParent().getDefaultCharset(); + } catch (CoreException e) { + charset = Constants.CHARACTER_ENCODING; + } + // Finally we could consider validating the content with respect + // to the content. We don't do that here. + String s = new String(bytes, charset); set(s); Activator.trace("(GitQuickDiffProvider) has reference doc, size=" + s.length() + " bytes"); } else { -- 1.6.1.rc3.56.gd0306 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html