From 5262f832018923ecc8ccd25bedecbd5a291a563f Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 11 Jul 2013 10:43:40 +1000 Subject: Include case conversion data in Scintilla so that all platforms will perform case conversion of Unicode text in accordance with Unicode. --- src/UnicodeFromUTF8.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/UnicodeFromUTF8.h (limited to 'src/UnicodeFromUTF8.h') diff --git a/src/UnicodeFromUTF8.h b/src/UnicodeFromUTF8.h new file mode 100644 index 000000000..24517e8a2 --- /dev/null +++ b/src/UnicodeFromUTF8.h @@ -0,0 +1,19 @@ +// Scintilla source code edit control +/** @file UnicodeFromUTF8.h + ** Lexer infrastructure. + **/ +// Copyright 2013 by Neil Hodgson +// This file is in the public domain. + +inline int UnicodeFromUTF8(const unsigned char *us) { + if (us[0] < 0xC2) { + return us[0]; + } else if (us[0] < 0xE0) { + return ((us[0] & 0x1F) << 6) + (us[1] & 0x3F); + } else if (us[0] < 0xF0) { + return ((us[0] & 0xF) << 12) + ((us[1] & 0x3F) << 6) + (us[2] & 0x3F); + } else if (us[0] < 0xF5) { + return ((us[0] & 0x7) << 18) + ((us[1] & 0x3F) << 12) + ((us[2] & 0x3F) << 6) + (us[3] & 0x3F); + } + return us[0]; +} -- cgit v1.2.3