intl/uconv/src/nsUnicodeToUTF8.h

branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
equal deleted inserted replaced
-1:000000000000 0:50b013f1fe52
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsUnicodeToUTF8_h___
7 #define nsUnicodeToUTF8_h___
8
9 #include "mozilla/Attributes.h"
10 #include "nsIUnicodeEncoder.h"
11
12 // Class ID for our UnicodeToUTF8 charset converter
13 // {7C657D18-EC5E-11d2-8AAC-00600811A836}
14 #define NS_UNICODETOUTF8_CID \
15 { 0x7c657d18, 0xec5e, 0x11d2, {0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36}}
16
17 #define NS_UNICODETOUTF8_CONTRACTID "@mozilla.org/intl/unicode/encoder;1?charset=UTF-8"
18
19 //#define NS_ERROR_UCONV_NOUNICODETOUTF8
20 // NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_UCONV, 0x31)
21
22 //----------------------------------------------------------------------
23 // Class nsUnicodeToUTF8 [declaration]
24
25 /**
26 * A character set converter from Unicode to UTF8.
27 *
28 * @created 05/Apr/1999
29 * @author Catalin Rotaru [CATA]
30 */
31 class nsUnicodeToUTF8 MOZ_FINAL : public nsIUnicodeEncoder
32 {
33 NS_DECL_ISUPPORTS
34
35 public:
36
37 /**
38 * Class constructor.
39 */
40 nsUnicodeToUTF8() {mHighSurrogate = 0;}
41
42 NS_IMETHOD Convert(const char16_t * aSrc,
43 int32_t * aSrcLength,
44 char * aDest,
45 int32_t * aDestLength);
46
47 NS_IMETHOD Finish(char * aDest, int32_t * aDestLength);
48
49 NS_IMETHOD GetMaxLength(const char16_t * aSrc, int32_t aSrcLength,
50 int32_t * aDestLength);
51
52 NS_IMETHOD Reset() {mHighSurrogate = 0; return NS_OK;}
53
54 NS_IMETHOD SetOutputErrorBehavior(int32_t aBehavior,
55 nsIUnicharEncoder * aEncoder, char16_t aChar) {return NS_OK;}
56
57 protected:
58 char16_t mHighSurrogate;
59
60 };
61
62 #endif /* nsUnicodeToUTF8_h___ */

mercurial