Let's talk about the encoding library
Do you know about the "encoding" library?
Overview
This provides ways to convert a text from an encoding to another, and in addition, it provides a way to print unicode to the console (which is not supported by default by
Where can I find it ?
- with EiffelStudio: $ISE_LIBRARY/library/encoding
- subversion: https://svn.eiffel.com/eiffelstudio/trunk/Src/library/encoding
The main interfaces
SYSTEM_ENCODINGS
This interface provides most used encoding, such as utf8, utf32, ISO-8859-1, ... and also has a convenient way to get the encoding of the system, or the console.
ENCODING
The main interface to convert a text from an encoding to another thanks to the function
Converting text from an encoding to another
For instance, if you want to convert a text from UTF-32 to ISO-8859-1 encoding
There are a few useful status reports like
{ENCODING}.last_conversion_successful: BOOLEAN : to ensure the conversion went well{ENCODING}.last_conversion_lost_data: BOOLEAN : to know if the last conversion lost data (could happen for instance when converting true unicode text to ISO-8859-1).{ENCODING}.last_conversion_string_32: STRING_32 : to get the unicode converted text.
You can also create a custom ENCODING by passing code page, most know are available via
Write unicode into the console
Thanks to the class
Alternative solutions
Note that Eiffel Base includes a
Related library
i18n the Internationalization and localization library
- i18n stands for InternationalizatioN (I+18 character+N).
- It provides Internationalization and localization functionalities.
- Please see $ISE_LIBRARY/library/i18n (or subversion https://svn.eiffel.com/eiffelstudio/trunk/Src/library/i18n )
- Documentation: http://dev.eiffel.com/Internationalization/User_guide
- And among others functionalities, it can provide encoding code page value to be used with the encoding library.