public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Dealing with CRLF in Rust printing
@ 2022-06-27 19:17 Ayush Singh
  2022-06-28  3:03 ` Michael D Kinney
  0 siblings, 1 reply; 2+ messages in thread
From: Ayush Singh @ 2022-06-27 19:17 UTC (permalink / raw)
  To: edk2-devel-groups-io
  Cc: Michael Kubacki, michael.d.kinney, jabeena.b.gaibusab, Jiewen Yao

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

This means it is now possible to do things like this:
```rust
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
screen.

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

[1]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.60println!.60.20for.20CRLF.20console

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Dealing with CRLF in Rust printing
  2022-06-27 19:17 Dealing with CRLF in Rust printing Ayush Singh
@ 2022-06-28  3:03 ` Michael D Kinney
  0 siblings, 0 replies; 2+ messages in thread
From: Michael D Kinney @ 2022-06-28  3:03 UTC (permalink / raw)
  To: Ayush Singh, edk2-devel-groups-io, Kinney, Michael D
  Cc: Michael Kubacki, Gaibusab, Jabeena B, Yao, Jiewen

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'.

Mike

> -----Original Message-----
> From: Ayush Singh <ayushdevel1325@gmail.com>
> Sent: Monday, June 27, 2022 12:17 PM
> To: edk2-devel-groups-io <devel@edk2.groups.io>
> Cc: Michael Kubacki <mikuback@linux.microsoft.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gaibusab, Jabeena B
> <jabeena.b.gaibusab@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> 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:
> ```rust
> 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
> screen.
> 
> 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
> 
> [1]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.60println!.60.20for.20CRLF.20console

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-28  3:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-27 19:17 Dealing with CRLF in Rust printing Ayush Singh
2022-06-28  3:03 ` Michael D Kinney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox