// 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.
String charset;
IEncodedStorage encodedStorage = ((IEncodedStorage) resource);
try {
charset = encodedStorage.getCharset();
if (charset == null)
charset = resource.getParent().getDefaultCharset();
} catch (CoreException e) {
charset = Constants.CHARACTER_ENCODING;
}