mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
Add and use str2wcstring(string, size_t)
This is just for convenience.
This commit is contained in:
parent
2de38ef7bf
commit
f9d883dd74
3 changed files with 7 additions and 1 deletions
|
@ -91,7 +91,7 @@ static const wchar_t *string_get_arg_stdin(wcstring *storage, const io_streams_t
|
|||
}
|
||||
|
||||
// Split the buffer on the '\n' and return the first part.
|
||||
*storage = str2wcstring(buffer.c_str(), pos);
|
||||
*storage = str2wcstring(buffer, pos);
|
||||
buffer.erase(0, pos + 1);
|
||||
return storage->c_str();
|
||||
}
|
||||
|
|
|
@ -290,6 +290,11 @@ wcstring str2wcstring(const std::string &in) {
|
|||
return str2wcs_internal(in.data(), in.size());
|
||||
}
|
||||
|
||||
wcstring str2wcstring(const std::string &in, size_t len) {
|
||||
// Handles embedded nulls!
|
||||
return str2wcs_internal(in.data(), len);
|
||||
}
|
||||
|
||||
char *wcs2str(const wchar_t *in) {
|
||||
if (!in) return NULL;
|
||||
size_t desired_size = MAX_UTF8_BYTES * wcslen(in) + 1;
|
||||
|
|
|
@ -285,6 +285,7 @@ int fgetws2(wcstring *s, FILE *f);
|
|||
wcstring str2wcstring(const char *in);
|
||||
wcstring str2wcstring(const char *in, size_t len);
|
||||
wcstring str2wcstring(const std::string &in);
|
||||
wcstring str2wcstring(const std::string &in, size_t len);
|
||||
|
||||
/// Returns a newly allocated multibyte character string equivalent of the specified wide character
|
||||
/// string.
|
||||
|
|
Loading…
Reference in a new issue