Update Tortoise.pot
[TortoiseGit.git] / ext / scintilla / src / UnicodeFromUTF8.h
blob71f224b69d8a73ed3314627f4d9b45b298a178f6
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