* @see org.eclipse.ui.editors.text.StorageDocumentProvider#getPersistedEncoding(java.lang.Object)
*/
protected String getPersistedEncoding(Object element) {
String charset = super.getPersistedEncoding(element);
if (charset == null && element instanceof IStorageEditorInput) {
IStorage storage;
try {
storage = ((IStorageEditorInput) element).getStorage();
if (storage != null && !(storage instanceof IEncodedStorage)) {
InputStream contents = null;
try {
contents = storage.getContents();
if (contents != null) {
QualifiedName[] detectionOptions = new QualifiedName[]{IContentDescription.BYTE_ORDER_MARK, IContentDescription.CHARSET};
IContentDescription description = Platform.getContentTypeManager().getDescriptionFor(contents, storage.getName(), detectionOptions);
if (description != null) {
charset = description.getCharset();
}
}