diff options
| author | Neil <nyamatongwe@gmail.com> | 2020-05-19 13:23:04 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2020-05-19 13:23:04 +1000 |
| commit | 9b9c12efef67a4f327f298e36a75b19d97a4735a (patch) | |
| tree | 49fc22e6bb2cfaacd2ebb63b6b5e033334b11b34 /src/UniConversion.h | |
| parent | ac2e28f9de128de48e1b43ca96bb8baa6d7aba41 (diff) | |
| download | scintilla-mirror-9b9c12efef67a4f327f298e36a75b19d97a4735a.tar.gz | |
Backport: Encapsulate common check for PS, LS, and NEL as UTF8IsMultibyteLineEnd.
Avoids construction of temporary array.
Backport of changeset 8242:0a852c639c21.
Diffstat (limited to 'src/UniConversion.h')
| -rw-r--r-- | src/UniConversion.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/UniConversion.h b/src/UniConversion.h index 979075f5a..0c7adff10 100644 --- a/src/UniConversion.h +++ b/src/UniConversion.h @@ -71,6 +71,13 @@ inline bool UTF8IsNEL(const unsigned char *us) noexcept { return (us[0] == 0xc2) && (us[1] == 0x85); } +// Is the sequence of 3 char a UTF-8 line end? Only the last two char are tested for a NEL. +constexpr bool UTF8IsMultibyteLineEnd(unsigned char ch0, unsigned char ch1, unsigned char ch2) noexcept { + return + ((ch0 == 0xe2) && (ch1 == 0x80) && ((ch2 == 0xa8) || (ch2 == 0xa9))) || + ((ch1 == 0xc2) && (ch2 == 0x85)); +} + enum { SURROGATE_LEAD_FIRST = 0xD800 }; enum { SURROGATE_LEAD_LAST = 0xDBFF }; enum { SURROGATE_TRAIL_FIRST = 0xDC00 }; |
