When to use which type of STRING in eiffel? I saw using READABLE_STRING_GENERAL
and having to l_readable_string.out' to convert it to
STRING`
READABLE_STRING_GENERAL
is an ancestor of all variants of strings: mutable, immutable, 8-bit, 32-bit, so it can be used as a formal argument type when the feature can handle any string variant.
READABLE_STRING_32
is a good choice when the code handles Unicode, and can work with either mutable or immutable versions.
STRING_32
is a mutable Unicode variant. The code can change its value.
STRING
is an alias for a string type that can either be STRING_8
or STRING_32
. At the time of writing only a few libraries are adapted to handle the mapping of STRING
to STRING_32
. However, this mapping could become the default in the future to facilitate working with Unicode.
Regardless of the future, I would recommend using ..._STRING_32
to process strings. This way the code directly supports Unicode. The libraries are also updated in this direction. For example, io.put_string_32
can be used to print a Unicode string to the standard output (using the current locale).