[Lldb-commits] [lldb] [lldb] Use LLVM's helper for Unicode conversion (NFC) (PR #112582)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 30 08:07:14 PDT 2024
================
@@ -1574,25 +1584,23 @@ bool Editline::CompleteCharacter(char ch, EditLineGetCharType &out) {
out = (unsigned char)ch;
return true;
#else
- LLDB_DEPRECATED_WARNING_DISABLE
- std::codecvt_utf8<wchar_t> cvt;
- LLDB_DEPRECATED_WARNING_RESTORE
llvm::SmallString<4> input;
for (;;) {
- const char *from_next;
- wchar_t *to_next;
- std::mbstate_t state = std::mbstate_t();
input.push_back(ch);
- switch (cvt.in(state, input.begin(), input.end(), from_next, &out, &out + 1,
- to_next)) {
- case std::codecvt_base::ok:
+ const char *cur_ptr = input.begin();
+ const char *end_ptr = input.end();
+ llvm::UTF32 code_point = 0;
+ llvm::ConversionResult cr = llvm::convertUTF8Sequence(
+ (const llvm::UTF8 **)&cur_ptr, (const llvm::UTF8 *)end_ptr, &code_point,
----------------
labath wrote:
```suggestion
auto *cur_ptr = reinterpret_cast<const llvm::UTF8 *>(input.begin());
auto *end_ptr = reinterpret_cast<const llvm::UTF8 *>(input.end());
llvm::UTF32 code_point = 0;
llvm::ConversionResult cr = llvm::convertUTF8Sequence(
&cur_ptr, end_ptr, &code_point,
```
I think this is "less undefined" :P
https://github.com/llvm/llvm-project/pull/112582
More information about the lldb-commits
mailing list