/usr/include/bt/Unicode.hh is in libbt-dev 0.70.1-36.
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
// Unicode.hh for Blackbox - an X11 Window manager
// Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <shaleh@debian.org>
// Copyright (c) 1997 - 2000, 2002 - 2005
// Bradley T Hughes <bhughes at trolltech.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef __Unicode_hh
#define __Unicode_hh
#include <string>
namespace bt
{
/*
* Returns true if the system supports Unicode conversions.
*/
bool hasUnicode();
/*
* Unicode character type.
*/
typedef unsigned int Uchar;
/*
* Unicode string type.
*/
typedef std::basic_string<Uchar> ustring;
/*
* Converts multibyte locale-encoded string to wide-char Unicode
* string (aka UTF-32).
*/
ustring toUnicode(const std::string &string);
/*
* Converts wide-char Unicode string (aka UTF-32) to multibyte
* locale-encoded string.
*/
std::string toLocale(const ustring &string);
/*
* Converts UTF-32 to UTF-8.
*/
std::string toUtf8(const ustring &utf32);
/*
* Convert UTF-8 to UTF-32.
*/
ustring toUtf32(const std::string &utf8);
} // namespace bt
/*
* Workaround incomplete std::char_traits<> implementation in come
* versions of the GNU C++ compiler.
*/
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
# if __GNUC__ == 3
namespace std {
template<>
struct char_traits<bt::Uchar>
{
typedef bt::Uchar char_type;
typedef unsigned int int_type;
typedef streampos pos_type;
typedef streamoff off_type;
typedef mbstate_t state_type;
static void
assign(bt::Uchar &c1, const bt::Uchar &c2)
{ c1 = c2; }
static bool
eq(const bt::Uchar &c1, const bt::Uchar &c2)
{ return c1 == c2; }
static bool
lt(const bt::Uchar &c1, const bt::Uchar &c2)
{ return c1 < c2; }
static int
compare(const bt::Uchar *s1, const bt::Uchar *s2, size_t n) {
for (size_t x = 0; x < n; ++x) {
if (lt(s1[x], s2[x]))
return -1;
if (lt(s2[x], s1[x]))
return 1;
}
return 0;
}
static size_t
length(const bt::Uchar *s)
{
size_t x = 0;
while (!eq(s[x], bt::Uchar()))
++x;
return x;
}
static const bt::Uchar *
find(const bt::Uchar *s, std::size_t n, const bt::Uchar &c)
{
for (std::size_t x = 0; x < n; ++x)
if (eq(s[x], c))
return s + x;
return 0;
}
static bt::Uchar *
move(bt::Uchar *d, const bt::Uchar *s, std::size_t n) {
return (static_cast<bt::Uchar *>
(std::memmove(d, s, n *sizeof(bt::Uchar ))));
}
static bt::Uchar *
copy(bt::Uchar *d, const bt::Uchar *s, std::size_t n) {
std::copy(s, s + n, d);
return d;
}
static bt::Uchar *
assign(bt::Uchar *s, std::size_t n, bt::Uchar c) {
std::fill_n(s, n, c);
return s;
}
static bt::Uchar
to_char_type(const unsigned int &c)
{ return c; }
static unsigned int
to_int_type(const bt::Uchar &c)
{ return c; }
static bool
eq_int_type(const unsigned int &c1, const unsigned int &c2)
{ return c1 == c2; }
static int_type
eof()
{ return static_cast<unsigned int>(EOF); }
static unsigned int
not_eof(const unsigned int &c)
{ return (c == eof()) ? 0 : c; }
};
} // namespace std
# endif // __GNUC__ == 3
#endif // __GNUC__ && !__INTEL_COMPILER
#endif // __Unicode_hh
|