Menu

[r1152]: / trunk / ext / scintilla / src / UnicodeFromUTF8.h  Maximize  Restore  History

Download this file

33 lines (27 with data), 750 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Scintilla source code edit control
/** @file UnicodeFromUTF8.h
** Lexer infrastructure.
**/
// Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
// This file is in the public domain.
#ifndef UNICODEFROMUTF8_H
#define UNICODEFROMUTF8_H
#ifdef SCI_NAMESPACE
namespace Scintilla {
#endif
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];
}
#ifdef SCI_NAMESPACE
}
#endif
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.