intl/uconv/ucvlatin/nsUTF16ToUnicode.h

branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
equal deleted inserted replaced
-1:000000000000 0:e9986b356805
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 nsUTF16ToUnicode_h_
7 #define nsUTF16ToUnicode_h_
8
9 #include "nsISupports.h"
10 #include "nsUCSupport.h"
11
12 // internal base class
13 class nsUTF16ToUnicodeBase : public nsBasicDecoderSupport
14 {
15 protected:
16 // ctor accessible only by child classes
17 nsUTF16ToUnicodeBase() { Reset();}
18
19 nsresult UTF16ConvertToUnicode(const char * aSrc,
20 int32_t * aSrcLength, char16_t * aDest,
21 int32_t * aDestLength, bool aSwapBytes);
22
23 public:
24 //--------------------------------------------------------------------
25 // Subclassing of nsDecoderSupport class [declaration]
26
27 NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
28 int32_t * aDestLength);
29 NS_IMETHOD Reset();
30
31 protected:
32 uint8_t mState;
33 // to store an odd byte left over between runs
34 uint8_t mOddByte;
35 // to store an odd high surrogate left over between runs
36 char16_t mOddHighSurrogate;
37 // to store an odd low surrogate left over between runs
38 char16_t mOddLowSurrogate;
39 };
40
41 // UTF-16 big endian
42 class nsUTF16BEToUnicode : public nsUTF16ToUnicodeBase
43 {
44 public:
45
46 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
47 char16_t * aDest, int32_t * aDestLength);
48 };
49
50 // UTF-16 little endian
51 class nsUTF16LEToUnicode : public nsUTF16ToUnicodeBase
52 {
53 public:
54
55 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
56 char16_t * aDest, int32_t * aDestLength);
57 };
58
59 // UTF-16 with BOM
60 class nsUTF16ToUnicode : public nsUTF16ToUnicodeBase
61 {
62 public:
63
64 nsUTF16ToUnicode() { Reset();}
65 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
66 char16_t * aDest, int32_t * aDestLength);
67
68 NS_IMETHOD Reset();
69
70 private:
71
72 enum Endian {kUnknown, kBigEndian, kLittleEndian};
73 Endian mEndian;
74 bool mFoundBOM;
75 };
76
77 #endif /* nsUTF16ToUnicode_h_ */

mercurial