[PATCH] D51558: [Windows] Convert from UTF-8 to UTF-16 when writing to a Windows console
Richard Smith - zygoloid via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 31 16:01:46 PDT 2018
rsmith added inline comments.
================
Comment at: llvm/lib/Support/raw_ostream.cpp:636
+ // Fall back to ::write if it wasn't valid UTF-8.
+ if (auto EC = sys::windows::UTF8ToUTF16(Data, WideText))
+ return false;
----------------
Just out of curiosity: what's the difference between this and `llvm::convertUTF8ToUTF16String`?
================
Comment at: llvm/lib/Support/raw_ostream.cpp:650
+ DWORD ActuallyWritten;
+ bool Success = ::WriteConsoleW((HANDLE)::_get_osfhandle(FD), &WideText[0],
+ WCharsToWrite, &ActuallyWritten,
----------------
zturner wrote:
> Can you test this with the following?
>
> ```
> outs() << "Test\nTest2";
> ```
>
> I'm wondering if the LF will be handled properly. I think part of what `::write` does is to transcode LF to CRLF. So if we're directly calling `WriteConsole`, we might not get this for free anymore.
I think you want `&WideText[WCharWritten]` here.
https://reviews.llvm.org/D51558
More information about the llvm-commits
mailing list