DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Frameworks
  4. Variable Width Character Encoding in Eclipse Editor

Variable Width Character Encoding in Eclipse Editor

Character encoding is still an important consideration when developing for embedded devices and other IoT devices.

Erich Styger user avatar by
Erich Styger
·
Dec. 31, 18 · Presentation
Like (2)
Save
Tweet
Share
8.10K Views

Join the DZone community and get the full member experience.

Join For Free

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 microcontrollers. In any case, Eclipse has you covered. This is especially helpful in dealing with non-ASCII character codes in comments:

Comment with UTF-8 in Eclipse

Comment With UTF-8 in Eclipse

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:

Cp1252 Encoding in Eclipse Luna

Cp1252 Encoding in Eclipse Luna

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 in MCUXpresso IDE

UTF-8 in MCUXpresso IDE

UTF-8 is a variable length encoding that encodes a single character into 1, 2, 3, or 4 bytes.

Source file using UTF-8 wide characters

Source file using UTF-8 wide characters

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:

Image title

Saving non-confirming characters

The ‘Select First Character’ is a good choice to find a 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:

Text File Encoding Workspace Preference

Text File Encoding Workspace Preference

Other than that, the default encoding for each file can be configured under the menu Preferences > General > Content Types:

General Content Types Encoding Settings

General Content Types Encoding Settings

Happy Encoding!

Links

  • LCp1252 Encoding: https://en.wikipedia.org/wiki/Windows-1252
  • UTF-8 Encoding: https://en.wikipedia.org/wiki/UTF-8
Eclipse Character encoding UTF-8

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • PostgreSQL: Bulk Loading Data With Node.js and Sequelize
  • Hidden Classes in Java 15
  • Kotlin Is More Fun Than Java And This Is a Big Deal
  • DevSecOps Benefits and Challenges

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: