|
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 nsUTF8ToUnicode_h___ |
|
7 #define nsUTF8ToUnicode_h___ |
|
8 |
|
9 #include "nsUCSupport.h" |
|
10 |
|
11 // Class ID for our UTF8ToUnicode charset converter |
|
12 // {5534DDC0-DD96-11d2-8AAC-00600811A836} |
|
13 #define NS_UTF8TOUNICODE_CID \ |
|
14 { 0x5534ddc0, 0xdd96, 0x11d2, {0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36}} |
|
15 |
|
16 #define NS_UTF8TOUNICODE_CONTRACTID "@mozilla.org/intl/unicode/decoder;1?charset=UTF-8" |
|
17 |
|
18 //#define NS_ERROR_UCONV_NOUTF8TOUNICODE |
|
19 // NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_UCONV, 0x31) |
|
20 |
|
21 //---------------------------------------------------------------------- |
|
22 // Class nsUTF8ToUnicode [declaration] |
|
23 |
|
24 |
|
25 /** |
|
26 * A character set converter from UTF8 to Unicode. |
|
27 * |
|
28 * @created 18/Mar/1998 |
|
29 * @modified 04/Feb/2000 |
|
30 * @author Catalin Rotaru [CATA] |
|
31 */ |
|
32 |
|
33 class nsUTF8ToUnicode : public nsBasicDecoderSupport |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Class constructor. |
|
39 */ |
|
40 nsUTF8ToUnicode(); |
|
41 |
|
42 protected: |
|
43 |
|
44 uint32_t mUcs4; // cached Unicode character |
|
45 uint8_t mState; // cached expected number of bytes per UTF8 character sequence |
|
46 uint8_t mBytes; |
|
47 bool mFirst; |
|
48 |
|
49 //-------------------------------------------------------------------- |
|
50 // Subclassing of nsDecoderSupport class [declaration] |
|
51 |
|
52 NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength, |
|
53 int32_t * aDestLength); |
|
54 |
|
55 //-------------------------------------------------------------------- |
|
56 // Subclassing of nsBasicDecoderSupport class [declaration] |
|
57 |
|
58 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength, |
|
59 char16_t * aDest, int32_t * aDestLength); |
|
60 |
|
61 //-------------------------------------------------------------------- |
|
62 // Subclassing of nsBasicDecoderSupport class [declaration] |
|
63 |
|
64 NS_IMETHOD Reset(); |
|
65 |
|
66 }; |
|
67 |
|
68 #endif /* nsUTF8ToUnicode_h___ */ |
|
69 |