aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/UniConversion.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2019-03-20 19:18:57 +1100
committerNeil <nyamatongwe@gmail.com>2019-03-20 19:18:57 +1100
commit31a735c8ec0a4f7c62b162cd1c173bfef76737c5 (patch)
treee7a3ad283f5b7c44d79cfbcdb78d8cdf34b68bf2 /src/UniConversion.h
parent4ac748ba2238d3abd5227918d8174507d8fa3ec1 (diff)
downloadscintilla-mirror-31a735c8ec0a4f7c62b162cd1c173bfef76737c5.tar.gz
Backport: Implement WStringFromUTF8 to simplify code that creates wstring objects for
regular expressions and calling the Win32 API. Backport of changeset 7325:6148329fb2f3, but replaced std::string_view usage with const char* and size_t components. Also used #ifdef instead of C++17 `if constexpr` at suggestion of Neil.
Diffstat (limited to 'src/UniConversion.h')
-rw-r--r--src/UniConversion.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/UniConversion.h b/src/UniConversion.h
index 4bb8875d0..9f405e1ed 100644
--- a/src/UniConversion.h
+++ b/src/UniConversion.h
@@ -19,7 +19,11 @@ void UTF8FromUTF16(const wchar_t *uptr, size_t tlen, char *putf, size_t len);
void UTF8FromUTF32Character(int uch, char *putf);
size_t UTF16Length(const char *s, size_t len);
size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen);
+size_t UTF32Length(const char *s, size_t len) noexcept;
size_t UTF32FromUTF8(const char *s, size_t len, unsigned int *tbuf, size_t tlen);
+// WStringFromUTF8 does the right thing when wchar_t is 2 or 4 bytes so
+// works on both Windows and Unix.
+std::wstring WStringFromUTF8(const char *s, size_t len);
unsigned int UTF16FromUTF32Character(unsigned int val, wchar_t *tbuf) noexcept;
bool UTF8IsValid(const char *s, size_t len) noexcept;
std::string FixInvalidUTF8(const std::string &text);