1 // Scintilla source code edit control
2 /** @file UnicodeFromUTF8.h
3 ** Lexer infrastructure.
5 // Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
6 // This file is in the public domain.
8 #ifndef UNICODEFROMUTF8_H
9 #define UNICODEFROMUTF8_H
15 inline int UnicodeFromUTF8(const unsigned char *us
) {
18 } else if (us
[0] < 0xE0) {
19 return ((us
[0] & 0x1F) << 6) + (us
[1] & 0x3F);
20 } else if (us
[0] < 0xF0) {
21 return ((us
[0] & 0xF) << 12) + ((us
[1] & 0x3F) << 6) + (us
[2] & 0x3F);
22 } else if (us
[0] < 0xF5) {
23 return ((us
[0] & 0x7) << 18) + ((us
[1] & 0x3F) << 12) + ((us
[2] & 0x3F) << 6) + (us
[3] & 0x3F);