Dealing with variable width character encoding as with UTF-8 is pretty much a standard these days, at least in the Desktop programming world. This is not so much true when programming embedded devices and microcontroller. In any case, Eclipse has you covered. This is especially helpful dealing with non-ASCII character codes in comments:
In older Eclipse versions (e.g. Luna) the default character encoding in the Eclipse editor on Windows is the Cp1252 which is limited to 8 bits:
More modern Eclipse versions (e.g. Eclipse Oxygen in MCUXpresso IDE 10.3) are using UTF-8 by default. I can check the encoding in the properties menu für a file or folder:
UTF-8 is a variable length encoding which encodes a single character into 1, 2, 3 or 4 bytes.
The ‘inherited from container’ means that the file is inheriting the settings from the container (or folder) where the file resides. If I try to save a file with characters not able to map to the selected encoding, Eclipse will warn me about this:
The ‘Select First Character’ is a good choice to find the place where things might not be compliant.
I still have legacy projects with non UTF-8 encoding, and I’m converting them to UTF-8 where applicable.
A helpful option is in the workspace preferences which configures the default text file encoding:
Other than that, the default encoding for each file can be configured under the menu Preferences > General > Content Types:
Happy Encoding 🙂
- Cp1252 Encoding: https://en.wikipedia.org/wiki/Windows-1252
- UTF-8 Encoding: https://en.wikipedia.org/wiki/UTF-8