Every now and then I need to do message traces in Microsoft 365 – and I often download an extended trace and just type something like this:
ifjke@turrican ✓ ~/Desktop $ less MTDetail_Message\ trace\ report\ -\ 2020-12-02T073921.461Z_1147e95b-82e2-490b-9e93-b25eec36888d.csv "MTDetail_Message\ trace\ report\ -\ 2020-12-02T073921.461Z_1147e95b-82e2-490b-9e93-b25eec36888d.csv" may be a binary file. See it anyway? ifjke@turrican ✓ ~/Desktop $
A CSV file as binary? Hmm, when opening it anyway it looks quite garbled indeed:
"^@d^@a^@t^@e^@_^@t^@i^@m^@e^@_^@u^@t^@c^@"^@,^@"^@c^@l^@i^@e^@n^@t^@_^@i^@p^@"^@,^@"^@c^@l
An experienced eye comes up with the right idea at once. This is Microsoft, they use UTF-16 a lot on Windows right? So if you need – convert it to UTF-8 for example with iconv:
iconv -f utf-16le -t utf-8 <input> > <output>
Maybe this will help someone who stumbles upon this issue. In general iconv is a swiss army knife when there is need to convert from (-f) one charset to (-t) another. With a simple iconv -l you can see a list of all supported charsets – https://linux.die.net/man/1/iconv
Another quite good tool is recode – https://linux.die.net/man/1/recode.
