1//
2// UTF8String.h
3//
4// Library: Foundation
5// Package: Text
6// Module: UTF8String
7//
8// Definition of the UTF8 string functions.
9//
10// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Foundation_UTF8String_INCLUDED
18#define Foundation_UTF8String_INCLUDED
19
20
21#include "Poco/Foundation.h"
22
23
24namespace Poco {
25
26
27struct Foundation_API UTF8
28 /// This class provides static methods that are UTF-8 capable variants
29 /// of the same functions in Poco/String.h.
30 ///
31 /// The various variants of icompare() provide case insensitive comparison
32 /// for UTF-8 encoded strings.
33 ///
34 /// toUpper(), toUpperInPlace(), toLower() and toLowerInPlace() provide
35 /// Unicode-based character case transformation for UTF-8 encoded strings.
36 ///
37 /// removeBOM() removes the UTF-8 Byte Order Mark sequence (0xEF, 0xBB, 0xBF)
38 /// from the beginning of the given string, if it's there.
39{
40 static int icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, std::string::const_iterator it2, std::string::const_iterator end2);
41 static int icompare(const std::string& str1, const std::string& str2);
42 static int icompare(const std::string& str1, std::string::size_type n1, const std::string& str2, std::string::size_type n2);
43 static int icompare(const std::string& str1, std::string::size_type n, const std::string& str2);
44 static int icompare(const std::string& str1, std::string::size_type pos, std::string::size_type n, const std::string& str2);
45 static int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n1, const std::string& str2, std::string::size_type pos2, std::string::size_type n2);
46 static int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n, const std::string& str2, std::string::size_type pos2);
47 static int icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, const std::string::value_type* ptr);
48 static int icompare(const std::string& str, std::string::size_type pos, const std::string::value_type* ptr);
49 static int icompare(const std::string& str, const std::string::value_type* ptr);
50
51 static std::string toUpper(const std::string& str);
52 static std::string& toUpperInPlace(std::string& str);
53 static std::string toLower(const std::string& str);
54 static std::string& toLowerInPlace(std::string& str);
55
56 static void removeBOM(std::string& str);
57 /// Remove the UTF-8 Byte Order Mark sequence (0xEF, 0xBB, 0xBF)
58 /// from the beginning of the string, if it's there.
59
60 static std::string escape(const std::string& s);
61 /// Escapes a string. Special characters like tab, backslash, ... are
62 /// escaped. Unicode characters are escaped to \uxxxx.
63
64 static std::string escape(const std::string::const_iterator& begin, const std::string::const_iterator& end);
65 /// Escapes a string. Special characters like tab, backslash, ... are
66 /// escaped. Unicode characters are escaped to \uxxxx.
67
68 static std::string unescape(const std::string& s);
69 /// Creates an UTF8 string from a string that contains escaped characters.
70
71 static std::string unescape(const std::string::const_iterator& begin, const std::string::const_iterator& end);
72 /// Creates an UTF8 string from a string that contains escaped characters.
73};
74
75
76} // namespace Poco
77
78
79#endif // Foundation_UTF8String_INCLUDED
80