Skip to content

logging functions handle unicode poorly #2154

Closed
@jesse99

Description

@jesse99

If I log a string with unicode I would like to see the unicode not some wacky utf-8 multi-byte escape sequence. Here is a test case:

// Run with export RUST_LOG=test && ./test
import io;

fn is_print(ch: char) -> bool
{
ret ch >= '_' && ch <= '~';
}

fn munge_chars(chars: [char]) -> str
{
let bullet = '\u2022';

let mut value = "";
str::reserve(value, vec::len(chars));
vec::iter(chars) {|ch| str::push_char(value, if is_print(ch) {ch} else {bullet});}
ret value;

}

fn main()
{
let s = munge_chars(['h', 'e', 'l', 'l', 'o', '\u0003']);

// With the terminal on Mac OSX this prints the following two lines:
// hello<bullet symbol>
// rust: "hello\xffffffe2\xffffff80\xffffffa2"
io::println(s);
#info("%s", s);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UnicodeArea: UnicodeA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions