mobiusklein / mzdata

Apache License 2.0
19 stars 4 forks source link

thermo raw file with µ character not loading #7

Closed RienLeuvenink closed 4 weeks ago

RienLeuvenink commented 1 month ago

as the title suggests. Thermo Raw files with a µ character is the file name are not loading. When I remove the character the issues is resolved. specific error below:

thread 'main' panicked at src\main.rs:481:6:
called `Result::unwrap()` on an `Err` value: Custom { kind: NotFound, error: "File not found" }
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\result.rs:1649
   3: enum2$<core::result::Result<mzdata::io::thermo::reader::ThermoRawReaderType<mzpeaks::peak::CentroidPeak,mzpeaks::peak::DeconvolutedPeak>,std::io::error::Error> >::unwrap<mzdata::io::thermo::reader::ThermoRawReaderType<mzpeaks::peak::CentroidPeak,mzpeaks::
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\core\src\result.rs:1073
   4: dumb_decon::main
             at .\src\main.rs:476
   5: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\core\src\ops\function.rs:250
   6: core::hint::black_box
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\core\src\hint.rs:286
douweschulte commented 1 month ago

We where thinking this might be caused by Rust using UTF8 and C# using UTF16, could this be the cause?

mobiusklein commented 1 month ago

Thank you for reporting this. It is a UTF-8 problem.

In thermorawfilereader's .NET layer I used Marshal.PtrToStringAnsi which mentions UTF-8 support in the tooltip but the online documentation states that is only on Unix. image

Switching to Marshal.PtrToStringUTF8 seems to fix the problem when tested on Windows using two different unicode \mus

I'll clean up the thermorawfilereader code with another change I was in the process of making and release new versions of that and then mzdata in the next day or so.

mobiusklein commented 4 weeks ago

This should be fixed with the latest tag (v0.28.0) which was just released. Please let me know if this fixed the problem.

RienLeuvenink commented 4 weeks ago

Yes it works now! Thanks