kamil Personally I hope to see it fixed properly and switched to wchar aware functions.
Looks like I was wrong in my analysis--and wchar-aware functions won't need to be implemented after all.
Not being familiar with Rust, I was unsure about what the string-like constanst I saw were: Unicode or UTF-8.
I was also wrong about Rust producing static binaries. Which means that as long as setlocale()
can be called from Rust, UTF-8 bytes can be used with the ncurses
addstr()
and mvaddstr()
functions.
I modified the example code in Tutorial 2, above, to call setlocale()
, and... no mojibake!
Here's the diff:
diff -u src/main.rs{.orig,}
--- src/main.rs.orig 2020-08-23 12:38:57.923805228 +0000
+++ src/main.rs 2020-08-23 12:40:00.565448799 +0000
@@ -1,7 +1,11 @@
use cursive::Cursive;
use cursive::views::Dialog;
+use std::ffi::CString;
fn main() {
+ unsafe {
+ libc::setlocale(libc::LC_ALL, CString::new("").unwrap().as_ptr());
+ }
let mut siv = cursive::default();
siv.add_layer(Dialog::text("This is a survey!\nPress <Next> when you're ready.")
@pin, can you add a setlocale()
call like that to ncspot
? Then, you can get somewho knows Rust to do a proper patch.
PS. How to do I edit my old posts? I'd like to put a strikethrough through that text so that people are not misinformed.