This file is indexed.

/usr/include/cwidget/generic/util/transcode.h is in libcwidget-dev 0.5.16-3.1ubuntu1.

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
// transcode.h                                      -*-c++-*-
//
//   Copyright (C) 2005 Daniel Burrows
//
//   This program is free software; you can redistribute it and/or
//   modify it under the terms of the GNU General Public License as
//   published by the Free Software Foundation; either version 2 of
//   the License, or (at your option) any later version.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//   General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; see the file COPYING.  If not, write to
//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
//   Boston, MA 02111-1307, USA.

#ifndef TRANSCODE_H
#define TRANSCODE_H

#include <string>

namespace cwidget
{
  namespace util
  {
    /** Convenience function to convert a multibyte encoding to wide
     *  characters.  This is a wrapper around iconv.
     *
     *  \param s the string to decode
     *  \param out the location to write the transcoded string
     *  \param encoding the encoding of s; if \b null or unspecified,
     *         the value of LC_CTYPE is used.
     *
     *  \return \b true if the entire string was successfully transcoded;
     *  if transcoding failed, returns \b false and sets errno.
     */
    bool transcode(const char *s,
		   std::wstring &out,
		   const char *encoding=NULL);

    inline bool transcode(const std::string &s,
			  std::wstring &out,
			  const char *encoding=NULL)
    {
      return transcode(s.c_str(), out, encoding);
    }

    /** The error handler for converting multibyte strings to wide
     *  strings: it is passed a partially-decoded string and the error
     *  code, and its return value becomes the return value of the
     *  function.  The default handler just returns "partial".
     */
    extern std::wstring (*transcode_mbtow_err)(int error,
					       const std::wstring &partial,
					       const std::string &input);

    /** Convenience function to convert a multibyte encoding to wide
     *  characters, where the caller doesn't need to directly handle
     *  errors.  This is a wrapper around iconv.
     *
     *  \param s the string to decode 
     *
     *  \param encoding the encoding of s; if \b null or unspecified, the
     *  value of LC_CTYPE is used.
     *
     *  \param errf the error handler, or \b null to use the default
     *  handler (transcode_mbtow_err).
     */
    std::wstring transcode(const std::string &s,
			   const char *encoding=NULL,
			   std::wstring (*errf)(int error,
						const std::wstring &partial,
						const std::string &input)=NULL);

    /** Convenience function to convert a multibyte encoding to wide
     *  characters, where the caller doesn't need to directly handle
     *  errors.  This is a wrapper around iconv.
     *
     *  \param s the string to decode 
     *
     *  \param encoding the encoding of s; if \b null or unspecified, the
     *  value of LC_CTYPE is used.
     *
     *  \param errf the error handler, or \b null to use the default
     *  handler (transcode_mbtow_err).
     */
    std::wstring transcode(const char *s,
			   const char *encoding=NULL,
			   std::wstring (*errf)(int error,
						const std::wstring &partial,
						const std::string &input)=NULL);

    // Note: would it be saner to express errors via exceptions?

    /** Convenience function to convert the native wide character encoding
     *  to a multibyte encoding.  This is a wrapper around iconv.
     *
     *  \param s the wide string to encode
     *  \param out the location to write the multibyte string
     *  \param encoding the encoding of out; if \b null or unspecified,
     *         the value of LC_CTYPE is used.
     *
     *  \return \b true if the entire string was successfully transcoded;
     *  if transcoding failed, returns \b false and sets errno.
     */
    bool transcode(const wchar_t *s,
		   std::string &out,
		   const char *encoding=NULL);


    inline bool transcode(const std::wstring &s,
			  std::string &out,
			  const char *encoding=NULL)
    {
      return transcode(s.c_str(), out, encoding);
    }


    /** The error handler for converting multibyte strings to wide
     *  strings: it is passed a partially-decoded string and the error
     *  code, and its return value becomes the return value of the
     *  function.  The default handler just returns "partial".
     */
    extern std::string (*transcode_wtomb_err)(int error,
					      const std::string &partial,
					      const std::wstring &input);

    /** Convenience function to convert a multibyte encoding to wide
     *  characters, where the caller doesn't need to directly handle
     *  errors.  This is a wrapper around iconv.
     *
     *  \param s the string to decode 
     *
     *  \param encoding the encoding of s; if \b null or unspecified, the
     *  value of LC_CTYPE is used.
     *
     *  \param errf the error handler, or \b null to use the default
     *  handler (transcode_mbtow_err).
     */
    std::string transcode(const std::wstring &s,
			  const char *encoding=NULL,
			  std::string (*errf)(int error,
					      const std::string &partial,
					      const std::wstring &input)=NULL);

    /** Convenience function to convert a multibyte encoding to wide
     *  characters, where the caller doesn't need to directly handle
     *  errors.  This is a wrapper around iconv.
     *
     *  \param s the string to decode 
     *
     *  \param encoding the encoding of s; if \b null or unspecified, the
     *  value of LC_CTYPE is used.
     *
     *  \param errf the error handler, or \b null to use the default
     *  handler (transcode_mbtow_err).
     */
    std::string transcode(const wchar_t *s,
			  const char *encoding=NULL,
			  std::string (*errf)(int error,
					      const std::string &partial,
					      const std::wstring &input)=NULL);
  }
}

#endif // TRANSCODE_H