~ubuntu-branches/ubuntu/karmic/gnash/karmic

« back to all changes in this revision

Viewing changes to libbase/utf8.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef UTF8_H
22
22
#define UTF8_H
23
23
 
24
 
#include "tu_config.h" // For DSOEXPORT
 
24
#include "dsodefs.h" // For DSOEXPORT
25
25
#include <string>
26
 
#include <boost/cstdint.hpp> // for boost::?int??_t
 
26
#include <boost/cstdint.hpp> // for C99 int types
27
27
 
28
28
/// Utilities to convert between std::string and std::wstring.
29
29
//
35
35
/// allowing many thousands of unique codes. Multibyte characters are 
36
36
/// difficult to handle, as their length - used for many string
37
37
/// operations - is not certain without parsing the string.
38
 
/// Converting the string to a wstring (generally a uint32_t - how
39
 
/// many codes the reference player can deal with is unknown)
40
 
/// facilitates string operations, as the length of the string
41
 
/// is equal to the number of valid characters. 
 
38
/// Converting the string to a wstring (generally a uint32_t - the 
 
39
/// pp seems only to handle characters up to 65535 - two bytes is
 
40
/// the minimum size of a wchar) facilitates string operations, as
 
41
/// the length of the string is equal to the number of valid characters. 
42
42
/// 
43
43
/// SWF5 and earlier, however, used the ISO-8859 specification,
44
44
/// allowing the standard 128 ASCII characters plus 128 extra
53
53
/// gnash::edit_text_character, ord() and chr().
54
54
namespace utf8
55
55
{
 
56
    static const boost::uint32_t invalid = -1;
 
57
 
56
58
        /// Converts a std::string with multibyte characters into a std::wstring.
57
59
        //
58
60
        /// @return a version-dependent wstring.
82
84
        /// as output.  Advances string iterator past the character
83
85
        /// returned, unless the returned character is '\0', in which
84
86
        /// case the iterator does not advance.
85
 
        boost::uint32_t decodeNextUnicodeCharacter(std::string::const_iterator& it);
 
87
        DSOEXPORT boost::uint32_t decodeNextUnicodeCharacter(std::string::const_iterator& it,
 
88
                                                             const std::string::const_iterator& e);
86
89
 
87
90
        /// \brief Encodes the given wide character into a canonical
88
91
        /// string, theoretically up to 6 chars in length.
89
 
        std::string encodeUnicodeCharacter(boost::uint32_t ucs_character);
 
92
        DSOEXPORT std::string encodeUnicodeCharacter(boost::uint32_t ucs_character);
90
93
        
91
94
        /// Encodes the given wide character into an at least 8-bit character.
92
95
        //
93
96
        /// Allows storage of Latin1 (ISO-8859-1) characters. This
94
97
        /// is the format of SWF5 and below.
95
98
        std::string encodeLatin1Character(boost::uint32_t ucsCharacter);
 
99
 
 
100
        enum TextEncoding {
 
101
                encUNSPECIFIED,
 
102
                encUTF8,
 
103
                encUTF16BE,
 
104
                encUTF16LE,
 
105
                encUTF32BE,
 
106
                encUTF32LE,
 
107
                encSCSU,
 
108
                encUTF7,
 
109
                encUTFEBCDIC,
 
110
                encBOCU1
 
111
        };
 
112
 
 
113
        /// Interpret (and skip) Byte Order Mark in input stream
 
114
        //
 
115
        /// This function takes a pointer to a buffer and returns
 
116
        /// the start of actual data after an eventual BOM.
 
117
        /// No conversion is performed, no bytes copy, just skipping of
 
118
        /// the BOM snippet and interpretation of it returned to the
 
119
        /// encoding input parameter.
 
120
        ///
 
121
        /// See http://en.wikipedia.org/wiki/Byte-order_mark
 
122
        ///
 
123
        /// @param in
 
124
        ///     The input buffer.
 
125
        ///
 
126
        /// @param size
 
127
        ///     Size of the input buffer, will be decremented by the
 
128
        ///     size of the BOM, if any.
 
129
        ///
 
130
        /// @param encoding
 
131
        ///     Output parameter, will always be set.
 
132
        ///     encUNSPECIFIED if no BOM is found.
 
133
        ///
 
134
        /// @returns
 
135
        ///     A pointer either equal to 'in' or some bytes inside it.
 
136
        ///
 
137
        DSOEXPORT char* stripBOM(char* in, size_t& size, TextEncoding& encoding);
 
138
 
 
139
        /// Return name of a text encoding
 
140
        DSOEXPORT const char* textEncodingName(TextEncoding enc);
96
141
}
97
142
 
98
143