/usr/include/Wt/WStringUtil is in libwt-dev 3.3.4+dfsg-6ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WSTRING_UTIL_H_
#define WSTRING_UTIL_H_
#include <string>
#include <Wt/WDllDefs.h>
#ifndef WT_NO_STD_LOCALE
#include <locale>
#else
#include <Wt/WGlobal>
#endif
namespace Wt {
#ifndef WT_NO_STD_WSTRING
/*! \brief Convert a narrow to a wide string.
*
* Convert a narrow string to a wide string. This method will interpret
* the input string as being encoded in the given locale (by default the
* currently configured global C++ locale).
*
* \sa narrow(const std::wstring&), fromUTF8(const std::string& s)
*
* \relates WString
*/
#ifndef WT_NO_STD_LOCALE
extern WT_API std::wstring widen(const std::string& s,
const std::locale &loc = std::locale());
#else
extern WT_API std::wstring widen(const std::string& s);
#endif // WT_NO_STD_LOCALE
#endif // WT_NO_STD_WSTRING
#ifndef WT_NO_STD_WSTRING
/*! \brief Convert a wide to a narrow string.
*
* Convert a wide string to a narrow string. This method will encode
* the characters in the given locale, if possible.
*
* In general this will lead to a loss of information. If you wish to
* preserve all information, you should us toUTF8() instead.
*
* \sa widen(const std::string&), toUTF8(const std::wstring& s)
*
* \relates WString
*/
#ifndef WT_NO_STD_LOCALE
extern WT_API std::string narrow(const std::wstring& s,
const std::locale &loc = std::locale());
#else
extern WT_API std::string narrow(const std::wstring& s);
#endif // WT_NO_STD_LOCALE
#endif // WT_NO_STD_WSTRING
#ifndef WT_NO_STD_WSTRING
/*! \brief Decode a UTF8 string a wide string.
*
* Decode a UTF8 string to a wide string. In a UTF8 encoded unicode string,
* some unicode characters are represented in more than one byte.
* This method will decode to extract the proper unicode characters from
* the string. The resulting string may thus be shorter (has less characters)
* than the original, but does not lead to a loss of information.
*
* \sa toUTF8(const std::string& s), narrow(const std::wstring&)
*
* \relates WString
*/
extern WT_API std::wstring fromUTF8(const std::string& s);
#endif // WT_NO_STD_WSTRING
/*! \brief Decode a UTF8 string into a (narrow) string.
*
* Decode a UTF8 string to a normal string.
* Not all Unicode characters can be represented in a narrow string,
* and quite a lot characters will have no equivalent in the target
* character set, so you may loose information.
*
* To distinguish from the other fromUTF8() function, that returns a
* wstring, the locale is not an optional argument, as in most other
* locale-conversing functions. You may choose to use the
* default-constructed std::locale().
*
* \sa toUTF8(const std::string& s, const std::locale &),
* fromUTF8(const std::string& s)
*
* \relates WString
*/
#ifndef WT_NO_STD_LOCALE
extern WT_API std::string fromUTF8(const std::string& s,
const std::locale &loc);
#else
// in order to be unambiguous with the fromUTF8 function that returns a
// wstring, this version takes an extra CharEncoding parameter.
extern WT_API std::string fromUTF8(const std::string& s,
CharEncoding encoding);
#endif
#ifndef WT_NO_STD_WSTRING
/*! \brief Encode a wide string to UTF8.
*
* Convert a wide string to UTF8. This method will encode the given
* wide string in UTF8. This may result in a string that is possibly
* longer (has more characters), but does not lead to a loss of
* information.
*
* \sa fromUTF8(const std::string& s), narrow(const std::wstring&)
*
* \relates WString
*/
extern WT_API std::string toUTF8(const std::wstring& s);
#endif // WT_NO_STD_WSTRING
/*! \brief Encode an character string (encoding known) to UTF8.
*
* Convert a char * string to UTF8. This method will encode the given
* string in UTF8, assuming that the original string was encoded in the
* given locale. This conversion does not lead to a loss of information.
*
* The reverse operation is in principle narrow(fromUTF8(str), locale).
*
* Do not call this function multiple times: toUTF8(toUTF8(str)) is
* meaningless.
*
* \sa toUTF8(const std::wstring& s), fromUTF8(const std::string &),
* narrow(const std::wstring&)
*
* \relates WString
*/
#ifndef WT_NO_STD_LOCALE
extern WT_API std::string toUTF8(const std::string& s,
const std::locale &loc = std::locale());
#else
extern WT_API std::string toUTF8(const std::string& s);
#endif
// Following is WT_API for testing
std::string WT_API UTF8Substr(const std::string &s, int begin, int length);
}
#endif // WSTRING_UTIL_H_
|