OMNeT++/OMNEST Bug Tracker - OMNeT++
View Issue Details
0000222OMNeT++IDE / NED editorpublic2010-12-10 07:442010-12-10 14:51
ViRe 
andras 
normaltextalways
resolvedfixed 
4.1 
4.2 
0000222: Chinese comments become gibberish in NED files.

If I use the "Clean up NED files..." function, the Chinese comments in my NED files will become gibberish.

//***********************************************************
//
// This is my file header
//

package src;

//
// 中文注释(Chinese Comments)
//
simple TestSimple
{
}
//***********************************************************

If I have a NED file like the upper one, and it is in the src folder. Now, I want to move the NED file into
another folder, so the package will be wrong. I can use the "Clean up NED files..." function to correct the
package. If I keep the NED Editor on, the Chinese comments still work right, but if I close the NED editor
when clean the NED files, the Chinese comments will become gibberish, like the following

//***********************************************************
//
// ???????(Chinese Comments)
//
simple TestSimple
{
}
//***********************************************************

In omnetpp4.1, the File header will be cleared too, but in 4.0, the File header will NOT be cleared.
No tags attached.
Issue History
2010-12-10 07:44ViReNew Issue
2010-12-10 14:50andrasNote Added: 0000347
2010-12-10 14:51andrasNote Added: 0000348
2010-12-10 14:51andrasStatusnew => resolved
2010-12-10 14:51andrasFixed in Version => 4.2
2010-12-10 14:51andrasResolutionopen => fixed
2010-12-10 14:51andrasAssigned To => andras

Notes
(0000347)
andras   
2010-12-10 14:50   
The error occurs because CleanupNedFilesAction writes out the changed files in the platform default encoding, instead of the file's own encoding. The Java code uses newContent.getBytes() instead of newContent.getBytes(file.getCharset()).

This causes a problem when NED files are in UTF-8, and the platform default encoding is some 8-bit format, e.g. ISO-8859-1 or Cp1252. Then newContent.getBytes() cannot represent the Chinese characters on 8 bits, and generates questions marks (?, x3F) instead. We'll this.

Workaround for 4.1: set the platform default encoding to UTF-8. This page can help: http://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding [^]
(0000348)
andras   
2010-12-10 14:51   
Fixed.

The bug also affected NED documentation generation; this was also fixed.