1 // Scintilla source code edit control
2 // Encoding: UTF-8
3 /** @file CaseConvert.h
4  ** Performs Unicode case conversions.
5  ** Does not handle locale-sensitive case conversion.
6  **/
7 // Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
8 // The License.txt file describes the conditions under which this software may be distributed.
9 
10 #ifndef CASECONVERT_H
11 #define CASECONVERT_H
12 
13 namespace Scintilla {
14 
15 enum CaseConversion {
16 	CaseConversionFold,
17 	CaseConversionUpper,
18 	CaseConversionLower
19 };
20 
21 class ICaseConverter {
22 public:
23 	virtual size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) = 0;
24 };
25 
26 ICaseConverter *ConverterFor(enum CaseConversion conversion);
27 
28 // Returns a UTF-8 string. Empty when no conversion
29 const char *CaseConvert(int character, enum CaseConversion conversion);
30 
31 // When performing CaseConvertString, the converted value may be up to 3 times longer than the input.
32 // Ligatures are often decomposed into multiple characters and long cases include:
33 // ΐ "\xce\x90" folds to ΐ "\xce\xb9\xcc\x88\xcc\x81"
34 const int maxExpansionCaseConversion=3;
35 
36 // Converts a mixed case string using a particular conversion.
37 // Result may be a different length to input and the length is the return value.
38 // If there is not enough space then 0 is returned.
39 size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed, enum CaseConversion conversion);
40 
41 // Converts a mixed case string using a particular conversion.
42 std::string CaseConvertString(const std::string &s, enum CaseConversion conversion);
43 
44 }
45 
46 #endif
47