Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C; tab-width: 4; 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 #ifndef nsISO2022KRToUnicode_h__
6 #define nsISO2022KRToUnicode_h__
7 #include "nsUCSupport.h"
8 #include "mozilla/Telemetry.h"
10 class nsISO2022KRToUnicode : public nsBasicDecoderSupport
11 {
12 public:
13 nsISO2022KRToUnicode()
14 {
15 mState = mState_Init;
16 mLastLegalState = mState_ASCII;
17 mData = 0;
18 mEUCKRDecoder = nullptr;
19 mRunLength = 0;
20 mozilla::Telemetry::Accumulate(
21 mozilla::Telemetry::DECODER_INSTANTIATED_ISO2022KR, true);
22 }
24 virtual ~nsISO2022KRToUnicode()
25 {
26 NS_IF_RELEASE(mEUCKRDecoder);
27 }
29 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
30 char16_t * aDest, int32_t * aDestLength) ;
32 NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
33 int32_t * aDestLength)
34 {
35 *aDestLength = aSrcLength;
36 return NS_OK;
37 }
39 NS_IMETHOD Reset()
40 {
41 mState = mState_Init;
42 mLastLegalState = mState_ASCII;
43 mRunLength = 0;
44 return NS_OK;
45 }
47 private:
48 enum {
49 mState_Init,
50 mState_ASCII,
51 mState_ESC,
52 mState_ESC_24,
53 mState_ESC_24_29,
54 mState_KSX1001_1992,
55 mState_KSX1001_1992_2ndbyte,
56 mState_ERROR
57 } mState, mLastLegalState;
59 uint8_t mData;
61 // Length of non-ASCII run
62 uint32_t mRunLength;
64 nsIUnicodeDecoder *mEUCKRDecoder;
65 };
66 #endif // nsISO2022KRToUnicode_h__