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 | |
24 | namespace Poco { |
25 | |
26 | |
27 | struct 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& (std::string& str); |
53 | static std::string toLower(const std::string& str); |
54 | static std::string& (std::string& str); |
55 | |
56 | static void (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, bool strictJSON = false); |
61 | /// Escapes a string. Special characters like tab, backslash, ... are |
62 | /// escaped. Unicode characters are escaped to \uxxxx. |
63 | /// If strictJSON is true, \a and \v will be escaped to \\u0007 and \\u000B |
64 | /// instead of \\a and \\v for strict JSON conformance. |
65 | |
66 | static std::string escape(const std::string::const_iterator& begin, const std::string::const_iterator& end, bool strictJSON = false); |
67 | /// Escapes a string. Special characters like tab, backslash, ... are |
68 | /// escaped. Unicode characters are escaped to \uxxxx. |
69 | /// If strictJSON is true, \a and \v will be escaped to \\u0007 and \\u000B |
70 | /// instead of \\a and \\v for strict JSON conformance. |
71 | |
72 | static std::string unescape(const std::string& s); |
73 | /// Creates an UTF8 string from a string that contains escaped characters. |
74 | |
75 | static std::string unescape(const std::string::const_iterator& begin, const std::string::const_iterator& end); |
76 | /// Creates an UTF8 string from a string that contains escaped characters. |
77 | }; |
78 | |
79 | |
80 | } // namespace Poco |
81 | |
82 | |
83 | #endif // Foundation_UTF8String_INCLUDED |
84 | |