print invalid strings

This commit is contained in:
dignifiedquire
2019-07-18 23:20:20 +02:00
committed by holger krekel
parent aaa5b820d9
commit e7a236264a

View File

@@ -1561,6 +1561,11 @@ pub fn to_string(s: *const libc::c_char) -> String {
let cstr = unsafe { CStr::from_ptr(s) };
cstr.to_str().map(|s| s.to_string()).unwrap_or_else(|err| {
eprintln!(
"Non utf8 string: '{:?}' ({:?})",
cstr.to_string_lossy(),
err
);
panic!("Non utf8 string: '{:?}' ({:?})", cstr.to_bytes(), err);
})
}