I have a ncurses project, where I use mvwprintw to print a long string to a window.
mvwprintw(traceview_window_flatprofile, 1, 0, "%s", flatprofile_as_str());
the result looks like this:
% self children self children
time time time calls /call /call name
39.86 886 µs 0 ns 32 27697 ns 0 ns addr_translate [13]
25.69 571 µs 1454 µs 1 571 µs 1454 µs main [0]
7.02 156 µs 0 ns 1 156 µs 0 ns addr_fini [66]
6.28 139 µs 55006 ns 1 139 µs 55006 ns addr_init [2]
3.83 85094 ns 21956 ns 2 42547 ns 10978 ns flatprofile_snprintf [43]
2.08 46150 ns 0 ns 1 46150 ns 0 ns addr_read_symbol_table [3]
When I print the same string to stderr, using
fprintf(stderr, "%s\n", flatprofile_as_str());
the result looks like:
% self children self children
time time time calls /call /call name
39.86 886 µs 0 ns 32 27697 ns 0 ns addr_translate [13]
25.69 571 µs 1454 µs 1 571 µs 1454 µs main [0]
7.02 156 µs 0 ns 1 156 µs 0 ns addr_fini [66]
6.28 139 µs 55006 ns 1 139 µs 55006 ns addr_init [2]
3.83 85094 ns 21956 ns 2 42547 ns 10978 ns flatprofile_snprintf [43]
2.08 46150 ns 0 ns 1 46150 ns 0 ns addr_read_symbol_table [3]
Do you know what could cause this difference?
EDIT: in addition to the answer below, the following question solves a related issue.
How to make ncurses display UTF-8 chars correctly in C?