How to print unicode to console in Eiffel?

Viewed 27

Evidently in python: print u'\u0420\u043e\u0441\u0441\u0438\u044f'

outputs: Россия

How do I do this in Eiffel?

1 Answers

On my linux OS, this code print exactly what you want:

make
        -- Initialisation of `Current'
    local
        l_utf_converter:UTF_CONVERTER
        l_string:STRING_32
    do
        create l_string.make_empty
        l_string.append_code (0x420)
        l_string.append_code (0x43e)
        l_string.append_code (0x441)
        l_string.append_code (0x441)
        l_string.append_code (0x438)
        l_string.append_code (0x44f)
        print(l_utf_converter.utf_32_string_to_utf_8_string_8 (l_string))
    end

In a nutshell, STRING_32 use UTF-32 and the linux console use UTF-8. The UTF_CONVERTER class can be use to convert UTF-32 to UTF-8.

I do not know if it is possible on a Windows console.

Related