2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifndef nsISO2022KRToUnicode_h__
|
|
|
|
#define nsISO2022KRToUnicode_h__
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsUCSupport.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class nsISO2022KRToUnicode : public nsBasicDecoderSupport
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsISO2022KRToUnicode()
|
|
|
|
{
|
2008-08-19 21:36:41 -07:00
|
|
|
mState = mState_Init;
|
2007-03-22 10:30:00 -07:00
|
|
|
mLastLegalState = mState_ASCII;
|
|
|
|
mData = 0;
|
2012-07-30 07:20:58 -07:00
|
|
|
mEUCKRDecoder = nullptr;
|
2007-09-05 22:02:17 -07:00
|
|
|
mRunLength = 0;
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual ~nsISO2022KRToUnicode()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mEUCKRDecoder);
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
|
|
|
|
PRUnichar * aDest, int32_t * aDestLength) ;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
|
|
|
|
int32_t * aDestLength)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aDestLength = aSrcLength;
|
|
|
|
return NS_OK;
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD Reset()
|
|
|
|
{
|
2008-08-19 21:36:41 -07:00
|
|
|
mState = mState_Init;
|
2007-03-22 10:30:00 -07:00
|
|
|
mLastLegalState = mState_ASCII;
|
2007-09-05 22:02:17 -07:00
|
|
|
mRunLength = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum {
|
2008-08-19 21:36:41 -07:00
|
|
|
mState_Init,
|
2007-03-22 10:30:00 -07:00
|
|
|
mState_ASCII,
|
|
|
|
mState_ESC,
|
|
|
|
mState_ESC_24,
|
|
|
|
mState_ESC_24_29,
|
|
|
|
mState_KSX1001_1992,
|
|
|
|
mState_KSX1001_1992_2ndbyte,
|
|
|
|
mState_ERROR
|
|
|
|
} mState, mLastLegalState;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mData;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-05 22:02:17 -07:00
|
|
|
// Length of non-ASCII run
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mRunLength;
|
2007-09-05 22:02:17 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIUnicodeDecoder *mEUCKRDecoder;
|
|
|
|
};
|
|
|
|
#endif // nsISO2022KRToUnicode_h__
|