Gnash
0.8.11dev
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
libbase
utf8.h
Go to the documentation of this file.
1
// utf8.h: utilities for converting to and from UTF-8
2
//
3
// Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
4
//
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
//
19
// Based on the public domain work of Thatcher Ulrich <tu@tulrich.com> 2004
20
21
#ifndef UTF8_H
22
#define UTF8_H
23
24
#include <string>
25
#include <boost/cstdint.hpp>
// for C99 int types
26
#include <vector>
27
28
#include "
dsodefs.h
"
// For DSOEXPORT
29
30
// Android doesn't have any support for wide characters at all.
31
#ifdef __ANDROID__
32
namespace
std {
33
typedef
basic_string
34
<wchar_t
35
,std::char_traits<wchar_t>
36
,std::allocator<wchar_t> >
37
wstring;
38
}
39
#endif
40
41
namespace
gnash {
42
44
//
66
//
70
namespace
utf8 {
71
73
//
77
//
80
DSOEXPORT
std::wstring
decodeCanonicalString
(
const
std::string& str,
int
version);
81
83
//
93
DSOEXPORT
std::string
encodeCanonicalString
(
const
std::wstring& wstr,
int
version);
94
96
//
101
DSOEXPORT
boost::uint32_t
decodeNextUnicodeCharacter
(std::string::const_iterator& it,
102
const
std::string::const_iterator&
e
);
103
106
DSOEXPORT
std::string
encodeUnicodeCharacter
(boost::uint32_t ucs_character);
107
109
//
112
DSOEXPORT
std::string
encodeLatin1Character
(boost::uint32_t ucsCharacter);
113
114
enum
TextEncoding
{
115
encUNSPECIFIED
,
116
encUTF8
,
117
encUTF16BE
,
118
encUTF16LE
,
119
encUTF32BE
,
120
encUTF32LE
,
121
encSCSU
,
122
encUTF7
,
123
encUTFEBCDIC
,
124
encBOCU1
125
};
126
128
//
151
DSOEXPORT
char
*
stripBOM
(
char
* in,
size_t
& size,
TextEncoding
& encoding);
152
154
DSOEXPORT
const
char
*
textEncodingName
(
TextEncoding
enc);
155
156
enum
EncodingGuess
{
157
ENCGUESS_UNICODE
= 0,
158
ENCGUESS_JIS
= 1,
159
ENCGUESS_OTHER
= 2
160
};
161
163
// Shift-Jis, UTF8, and other. Puts the DisplayObject count in length,
164
// and the offsets to the DisplayObjects in offsets, if offsets is not NULL.
165
// If not NULL, offsets should be at least s.length().
166
// offsets are not accurate if the return value is GUESSENC_OTHER
167
//
170
DSOEXPORT
EncodingGuess
guessEncoding
(
const
std::string&
s
,
int
&
length
,
171
std::vector<int>& offsets);
172
173
174
}
// namespace utf8
175
}
// namespace gnash
176
177
#endif // UTF8_H
178
179
180
// Local Variables:
181
// mode: C++
182
// c-basic-offset: 8
183
// tab-width: 8
184
// indent-tabs-mode: t
185
// End:
Generated on Sat Nov 30 2013 06:54:23 for Gnash by
1.8.1.2