mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Add a variant of wcs2string which accepts a ptr, length pair
This will be useful when refactoring separated buffers.
This commit is contained in:
parent
86a12e1abd
commit
fc97151aec
2 changed files with 6 additions and 3 deletions
|
@ -406,10 +406,12 @@ wcstring str2wcstring(const std::string &in, size_t len) {
|
|||
return str2wcs_internal(in.data(), len);
|
||||
}
|
||||
|
||||
std::string wcs2string(const wcstring &input) {
|
||||
std::string wcs2string(const wcstring &input) { return wcs2string(input.data(), input.size()); }
|
||||
|
||||
std::string wcs2string(const wchar_t *in, size_t len) {
|
||||
std::string result;
|
||||
result.reserve(input.size());
|
||||
wcs2string_callback(input.data(), input.size(), [&](const char *buff, size_t bufflen) {
|
||||
result.reserve(len);
|
||||
wcs2string_callback(in, len, [&](const char *buff, size_t bufflen) {
|
||||
result.append(buff, bufflen);
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -291,6 +291,7 @@ wcstring str2wcstring(const std::string &in, size_t len);
|
|||
/// This function decodes illegal character sequences in a reversible way using the private use
|
||||
/// area.
|
||||
std::string wcs2string(const wcstring &input);
|
||||
std::string wcs2string(const wchar_t *in, size_t len);
|
||||
|
||||
// Check if we are running in the test mode, where we should suppress error output
|
||||
#define TESTS_PROGRAM_NAME L"(ignore)"
|
||||
|
|
Loading…
Reference in a new issue