Re: Dealing with CRLF in Rust printing

Michael D Kinney

Hi Ayush,

Your proposal looks right to me.

If \r is printed from Rust, it should not be modified. Only if
a \n is printed from Rust should it be expanded to \r\n.

So your example of '\r\r\n' from Rust would be expanded to '\r\r\r\n'.


-----Original Message-----
From: Ayush Singh <ayushdevel1325@...>
Sent: Monday, June 27, 2022 12:17 PM
To: edk2-devel-groups-io <>
Cc: Michael Kubacki <mikuback@...>; Kinney, Michael D <michael.d.kinney@...>; Gaibusab, Jabeena B
<jabeena.b.gaibusab@...>; Yao, Jiewen <jiewen.yao@...>
Subject: Dealing with CRLF in Rust printing

Hello everyone, I have been somewhat successful in implementing Rust
stdio for UEFI.

This means it is now possible to do things like this:
let s = 10;
println!("ConOut: {}", s);
eprintl!("StdErr: {}", s);

However, Rust uses LF on all platforms currently, which means that the
`println!`, `eprintln!` and other macros only output LF at the end.

After discussion in zulipchat [1], it seems that rather than changing
the macro, it would be better to change what is printed as output.
This means changing: `\n` to `\r\n`, when we go for printing to

Note: This means that the LF will be changed to CRLF only when using
stdio and not when writing to say an external file.

Firstly, I wanted to ask other people's opinions about doing this.
Secondly, I wanted to ask if `\r\r\n` is the same as `\r\n` or if the
extra CR should be trimmed.

Ayush Singh


Join to automatically receive all group messages.