gecko-dev/intl/uconv/ucvja2/nsISO2022JPToUnicode.h

95 lines
2.6 KiB
C
Raw Normal View History

1999-02-12 19:35:59 +00:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsISO2022JPToUnicode_h___
#define nsISO2022JPToUnicode_h___
1999-04-23 22:14:11 +00:00
#include "nsUCvJa2Support.h"
1999-02-25 13:15:07 +00:00
//----------------------------------------------------------------------
// Class nsISO2022JPToUnicode [declaration]
1999-02-12 19:35:59 +00:00
/**
1999-02-25 13:15:07 +00:00
* A character set converter from ISO-2022-JP to Unicode.
*
* The state machine is:
* S0 + ESC -> S1
* S0 + * -> S0; convert using the current mCharset
* S1 + '(' -> S2
* S1 + '$' -> S3
* S1 + * -> ERR
* S2 + 'B' -> S0; mCharset = kASCII
* S2 + 'J' -> S0; mCharset = kJISX0201_1976
* S2 + * -> ERR
* S3 + '@' -> S0; mCharset = kJISX0208_1978
* S3 + 'B' -> S0; mCharset = kJISX0208_1983
* S3 + * -> ERR
* ERR + * -> ERR
*
1999-02-12 19:35:59 +00:00
* @created 09/Feb/1998
* @author Catalin Rotaru [CATA]
*/
1999-04-23 22:14:11 +00:00
class nsISO2022JPToUnicode : public nsBufferDecoderSupport
1999-02-12 19:35:59 +00:00
{
public:
/**
* Class constructor.
*/
1999-02-25 13:15:07 +00:00
nsISO2022JPToUnicode();
1999-02-12 19:35:59 +00:00
/**
* Class destructor.
*/
1999-02-26 16:58:33 +00:00
virtual ~nsISO2022JPToUnicode();
1999-02-25 13:15:07 +00:00
/**
* Static class constructor.
*/
1999-04-23 22:14:11 +00:00
static nsresult CreateInstance(nsISupports ** aResult);
1999-02-12 19:35:59 +00:00
1999-04-23 22:14:11 +00:00
protected:
1999-02-12 19:35:59 +00:00
1999-02-25 13:15:07 +00:00
enum {
kASCII,
kJISX0201_1976,
kJISX0208_1978,
kJISX0208_1983
};
1999-02-12 19:35:59 +00:00
1999-02-25 13:15:07 +00:00
PRInt32 mState; // current state of the state machine
PRInt32 mCharset; // current character set
1999-04-23 22:14:11 +00:00
nsIUnicodeDecodeHelper * mHelper; // decoder helper object
1999-02-12 19:35:59 +00:00
1999-04-23 22:14:11 +00:00
NS_IMETHOD ConvertBuffer(const char ** aSrc, const char * aSrcEnd,
1999-02-25 13:15:07 +00:00
PRUnichar ** aDest, PRUnichar * aDestEnd);
1999-04-23 22:14:11 +00:00
//--------------------------------------------------------------------
// Subclassing of nsBufferDecoderSupport class [declaration]
NS_IMETHOD ConvertNoBuff(const char * aSrc, PRInt32 * aSrcLength,
PRUnichar * aDest, PRInt32 * aDestLength);
NS_IMETHOD GetMaxLength(const char * aSrc, PRInt32 aSrcLength,
PRInt32 * aDestLength);
NS_IMETHOD Reset();
1999-02-25 13:15:07 +00:00
};
1999-02-12 19:35:59 +00:00
#endif /* nsISO2022JPToUnicode_h___ */