michael@0: /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef nsISO2022KRToUnicode_h__ michael@0: #define nsISO2022KRToUnicode_h__ michael@0: #include "nsUCSupport.h" michael@0: #include "mozilla/Telemetry.h" michael@0: michael@0: class nsISO2022KRToUnicode : public nsBasicDecoderSupport michael@0: { michael@0: public: michael@0: nsISO2022KRToUnicode() michael@0: { michael@0: mState = mState_Init; michael@0: mLastLegalState = mState_ASCII; michael@0: mData = 0; michael@0: mEUCKRDecoder = nullptr; michael@0: mRunLength = 0; michael@0: mozilla::Telemetry::Accumulate( michael@0: mozilla::Telemetry::DECODER_INSTANTIATED_ISO2022KR, true); michael@0: } michael@0: michael@0: virtual ~nsISO2022KRToUnicode() michael@0: { michael@0: NS_IF_RELEASE(mEUCKRDecoder); michael@0: } michael@0: michael@0: NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength, michael@0: char16_t * aDest, int32_t * aDestLength) ; michael@0: michael@0: NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength, michael@0: int32_t * aDestLength) michael@0: { michael@0: *aDestLength = aSrcLength; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHOD Reset() michael@0: { michael@0: mState = mState_Init; michael@0: mLastLegalState = mState_ASCII; michael@0: mRunLength = 0; michael@0: return NS_OK; michael@0: } michael@0: michael@0: private: michael@0: enum { michael@0: mState_Init, michael@0: mState_ASCII, michael@0: mState_ESC, michael@0: mState_ESC_24, michael@0: mState_ESC_24_29, michael@0: mState_KSX1001_1992, michael@0: mState_KSX1001_1992_2ndbyte, michael@0: mState_ERROR michael@0: } mState, mLastLegalState; michael@0: michael@0: uint8_t mData; michael@0: michael@0: // Length of non-ASCII run michael@0: uint32_t mRunLength; michael@0: michael@0: nsIUnicodeDecoder *mEUCKRDecoder; michael@0: }; michael@0: #endif // nsISO2022KRToUnicode_h__