From 5262f832018923ecc8ccd25bedecbd5a291a563f Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 11 Jul 2013 10:43:40 +1000 Subject: Include case conversion data in Scintilla so that all platforms will perform case conversion of Unicode text in accordance with Unicode. --- src/CaseConvert.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/CaseConvert.h (limited to 'src/CaseConvert.h') diff --git a/src/CaseConvert.h b/src/CaseConvert.h new file mode 100644 index 000000000..60de22799 --- /dev/null +++ b/src/CaseConvert.h @@ -0,0 +1,47 @@ +// Scintilla source code edit control +// Encoding: UTF-8 +/** @file CaseConvert.h + ** Performs Unicode case conversions. + ** Does not handle locale-sensitive case conversion. + **/ +// Copyright 2013 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef CASECONVERT_H +#define CASECONVERT_H + +#ifdef SCI_NAMESPACE +namespace Scintilla { +#endif + +enum CaseConversion { + CaseConversionFold, + CaseConversionUpper, + CaseConversionLower +}; + +class ICaseConverter { +public: + virtual size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) = 0; +}; + +ICaseConverter *ConverterFor(enum CaseConversion conversion); + +// Returns a UTF-8 string. Empty when no conversion +const char *CaseConvert(int character, enum CaseConversion conversion); + +// When performing CaseConvertString, the converted value may be up to 3 times longer than the input. +// Ligatures are often decomposed into multiple characters and long cases include: +// ΐ "\xce\x90" folds to ΐ "\xce\xb9\xcc\x88\xcc\x81" +const int maxExpansionCaseConversion=3; + +// Converts a mixed case string using a particular conversion. +// Result may be a different length to input and the length is the return value. +// If there is not enough space then 0 is returned. +size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed, enum CaseConversion conversion); + +#ifdef SCI_NAMESPACE +} +#endif + +#endif -- cgit v1.2.3