MCPcopy Create free account
hub / github.com/DFHack/dfhack / toLocaleMB

Function toLocaleMB

library/Console-posix.cpp:185–198  ·  view source on GitHub ↗

Convert a UTF-32 string back to locale defined multibyte coding.

Source from the content-addressed store, hash-verified

183
184//! Convert a UTF-32 string back to locale defined multibyte coding.
185static std::string toLocaleMB(const u32string& wstr)
186{
187 std::stringstream ss{};
188 char mb[MB_CUR_MAX];
189 std::mbstate_t state{};
190 const size_t err = -1;
191 for (auto ch: wstr) {
192 size_t sz = c32rtomb(mb, ch, &state);
193 if (sz == err)
194 break;
195 ss.write(mb, sz);
196 }
197 return ss.str();
198}
199
200namespace DFHack
201{

Callers 3

lineeditMethod · 0.85
prompt_refreshMethod · 0.85
prompt_loopMethod · 0.85

Calls 3

c32rtombFunction · 0.85
writeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected