Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321493

Summary: [editor] encoding problem for non ASCII characters
Product: [Modeling] OCL Reporter: Ed Willink <ed>
Component: CoreAssignee: OCL Inbox <mdt-ocl-inbox>
Status: CLOSED FIXED QA Contact: Ed Willink <ed>
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 3.0.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Eliminate spurious encoding none

Description Ed Willink CLA 2010-08-02 07:08:20 EDT
In the OCLinEcore editor, if a non ASCII character such as opening double quote, or closing double quote is saved in an annotation body, the file save appears to succeed but actually nothing happens.
Comment 1 Ed Willink CLA 2010-08-02 07:11:33 EDT
Correction: There is a stderr message on the Console Log

org.eclipse.core.runtime.CoreException: Some characters cannot be mapped using "Cp1252" character encoding.
Either change the encoding or remove the characters which are not supported by the "Cp1252" character encoding.
	at org.eclipse.ui.editors.text.FileDocumentProvider.doSaveDocument(FileDocumentProvider.java:609)
	at org.eclipse.ocl.examples.xtext.oclinecore.ui.model.OCLinEcoreDocumentProvider.doSaveDocument(OCLinEcoreDocumentProvider.java:82)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider$1$SaveOperation.execute(AbstractDocumentProvider.java:610)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider$DocumentProviderOperation.run(AbstractDocumentProvider.java:74)
	at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:69)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
	at org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:75)
	at org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:65)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider.executeOperation(AbstractDocumentProvider.java:551)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider.saveDocument(AbstractDocumentProvider.java:629)
	at org.eclipse.ui.texteditor.AbstractTextEditor.performSave(AbstractTextEditor.java:4868)
	at org.eclipse.ui.texteditor.AbstractTextEditor.doSave(AbstractTextEditor.java:4657)
	at org.eclipse.xtext.ui.editor.XtextEditor.doSave(XtextEditor.java:184)
Comment 2 Ed Willink CLA 2010-08-02 10:27:20 EDT
Lack of diagnostic is a TODO e.printStackTrace() at OCLinEcoreDocumentProvider line 85.

Problem is that saveAsEcore encodes the Unicode as UTF-8 for XMI which has a 0x80 byte that cannot be (re-)encoded as anything. This can be fixed by using a StringWriter rather than a ByteArrayOutputStream to serialize the Ecore XMI document.

If the file folder is directly or indirectly set to UTF-8 encoding reading and writing of eg \u201c then works.
Comment 3 Ed Willink CLA 2010-08-02 16:31:53 EDT
Created attachment 175732 [details]
Eliminate spurious encoding

Attached uses StringWriter to avoid encoding.
Comment 4 Ed Willink CLA 2010-08-17 13:11:45 EDT
Committed to HEAD for 3.1.0M2 and to R3_0_maintenance for 3.0.1RC2.
Comment 5 Ed Willink CLA 2011-05-27 03:13:47 EDT
Closing