From: Michal Suchanek Date: 2007-12-29T09:59:43+09:00 Subject: locale in ruby Hello I tried to make the curses extension work with utf-8. It is possible but it requires setting locale properly which Ruby currently does not do. It also requires ncursesw but these are typically available on systems that do multibyte terminal IO. Generally Ruby should be able to work with multiple encodings so it might seem that setting the locale does not make sense. However, the locale variables are used to set the default IO encoding. Some libraries like ncurses use the locale information to determine which characters are printable and won't work without a call to setlocale. This makes sense as the library is used for UI which should respect the locale settings. It is possible to do the call in the extension itself but this is the wrong place. Multiple extensions could stomp on each other when setting the locale. If the libruby in linked to a program other than ruby and the extension is loaded it may break the settings of the program. So it appears that the right place would be to set the locale during the interpreter's initialization from the environment, and allow other applications using ruby to deal with locale themselves. Some libc routines might behave differently when locale is set, there is at least one comment about setlocale in the ruby source. However, not setting the locale only hides improper use of these routines. These should be only used for presenting information to the user - the UI. So the only place for such routines might be the inspect method if they should be used at all. Since ruby extensions and applications using libruby might use setlocale it is a bug if some parts of ruby depend on the locale to be left at POSIX for correct operation. Thanks Michal