Merge pull request #826 from kugel-/doxygen-fixes2
[geany-mirror.git] / scintilla / src / UnicodeFromUTF8.h
blobae66cb0a928a18405d2ea6d3f7b7789dfcedf6c2
1 // Scintilla source code edit control
2 /** @file UnicodeFromUTF8.h
3 ** Lexer infrastructure.
4 **/
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
11 #ifdef SCI_NAMESPACE
12 namespace Scintilla {
13 #endif
15 inline int UnicodeFromUTF8(const unsigned char *us) {
16 if (us[0] < 0xC2) {
17 return us[0];
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);
25 return us[0];
28 #ifdef SCI_NAMESPACE
30 #endif
32 #endif