intl/uconv/ucvja/nsJapaneseToUnicode.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/uconv/ucvja/nsJapaneseToUnicode.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,146 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +#ifndef nsShiftJISToUnicode_h__
     1.9 +#define nsShiftJISToUnicode_h__
    1.10 +#include "nsUCSupport.h"
    1.11 +#include "mozilla/Telemetry.h"
    1.12 +
    1.13 +class nsShiftJISToUnicode : public nsBasicDecoderSupport
    1.14 +{
    1.15 +public:
    1.16 +
    1.17 + nsShiftJISToUnicode() 
    1.18 +     { 
    1.19 +         mState=0; mData=0; 
    1.20 +     }
    1.21 + virtual ~nsShiftJISToUnicode() {}
    1.22 +
    1.23 + NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    1.24 +     char16_t * aDest, int32_t * aDestLength) ;
    1.25 + NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
    1.26 +     int32_t * aDestLength) 
    1.27 +     {
    1.28 +        *aDestLength = aSrcLength;
    1.29 +        return NS_OK;
    1.30 +     }
    1.31 + NS_IMETHOD Reset()
    1.32 +     {
    1.33 +        mState = 0;
    1.34 +        return NS_OK;
    1.35 +     }
    1.36 +
    1.37 +  virtual char16_t GetCharacterForUnMapped();
    1.38 +
    1.39 +private:
    1.40 +
    1.41 +private:
    1.42 + int32_t  mState;
    1.43 + int32_t mData;
    1.44 +};
    1.45 +
    1.46 +class nsEUCJPToUnicodeV2 : public nsBasicDecoderSupport
    1.47 +{
    1.48 +public:
    1.49 +
    1.50 + nsEUCJPToUnicodeV2() 
    1.51 +     { 
    1.52 +          mState=0; mData=0; 
    1.53 +     }
    1.54 + virtual ~nsEUCJPToUnicodeV2() {}
    1.55 +
    1.56 + NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    1.57 +     char16_t * aDest, int32_t * aDestLength) ;
    1.58 + NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
    1.59 +     int32_t * aDestLength) 
    1.60 +     {
    1.61 +        *aDestLength = aSrcLength;
    1.62 +        return NS_OK;
    1.63 +     }
    1.64 + NS_IMETHOD Reset()
    1.65 +     {
    1.66 +        mState = 0;
    1.67 +        return NS_OK;
    1.68 +     }
    1.69 +
    1.70 +private:
    1.71 + int32_t  mState;
    1.72 + int32_t mData;
    1.73 +};
    1.74 + 
    1.75 +class nsISO2022JPToUnicodeV2 : public nsBasicDecoderSupport
    1.76 +{
    1.77 +public:
    1.78 +
    1.79 + nsISO2022JPToUnicodeV2() 
    1.80 +     { 
    1.81 +        mState = mState_ASCII;
    1.82 +        mLastLegalState = mState_ASCII;
    1.83 +        mData = 0;
    1.84 +        mRunLength = 0;
    1.85 +        G2charset = G2_unknown;
    1.86 +        mGB2312Decoder = nullptr;
    1.87 +        mEUCKRDecoder = nullptr;
    1.88 +        mISO88597Decoder = nullptr;
    1.89 +        mozilla::Telemetry::Accumulate(
    1.90 +          mozilla::Telemetry::DECODER_INSTANTIATED_ISO2022JP, true);
    1.91 +     }
    1.92 + virtual ~nsISO2022JPToUnicodeV2()
    1.93 +     {
    1.94 +        NS_IF_RELEASE(mGB2312Decoder);
    1.95 +        NS_IF_RELEASE(mEUCKRDecoder);
    1.96 +        NS_IF_RELEASE(mISO88597Decoder);
    1.97 +     }
    1.98 +
    1.99 + NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
   1.100 +     char16_t * aDest, int32_t * aDestLength) ;
   1.101 + NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
   1.102 +     int32_t * aDestLength) 
   1.103 +     {
   1.104 +        *aDestLength = aSrcLength;
   1.105 +        return NS_OK;
   1.106 +     }
   1.107 + NS_IMETHOD Reset()
   1.108 +     {
   1.109 +        mState = mState_ASCII;
   1.110 +        mLastLegalState = mState_ASCII;
   1.111 +        mRunLength = 0;
   1.112 +        return NS_OK;
   1.113 +     }
   1.114 +
   1.115 +private:
   1.116 + enum {
   1.117 +   mState_ASCII,
   1.118 +   mState_ESC,
   1.119 +   mState_ESC_28,
   1.120 +   mState_ESC_24,
   1.121 +   mState_ESC_24_28,
   1.122 +   mState_JISX0201_1976Roman,
   1.123 +   mState_JISX0201_1976Kana,
   1.124 +   mState_JISX0208_1978,
   1.125 +   mState_GB2312_1980,
   1.126 +   mState_JISX0208_1983,
   1.127 +   mState_KSC5601_1987,
   1.128 +   mState_JISX0212_1990,
   1.129 +   mState_JISX0208_1978_2ndbyte,
   1.130 +   mState_GB2312_1980_2ndbyte,
   1.131 +   mState_JISX0208_1983_2ndbyte,
   1.132 +   mState_KSC5601_1987_2ndbyte,
   1.133 +   mState_JISX0212_1990_2ndbyte,
   1.134 +   mState_ESC_2e,
   1.135 +   mState_ESC_4e,
   1.136 +   mState_ERROR
   1.137 + } mState, mLastLegalState;
   1.138 + int32_t mData;
   1.139 + int32_t mRunLength; // the length of a non-ASCII run
   1.140 + enum {
   1.141 +   G2_unknown,
   1.142 +   G2_ISO88591,
   1.143 +   G2_ISO88597
   1.144 + } G2charset;
   1.145 + nsIUnicodeDecoder *mGB2312Decoder;
   1.146 + nsIUnicodeDecoder *mEUCKRDecoder;
   1.147 + nsIUnicodeDecoder *mISO88597Decoder;
   1.148 +};
   1.149 +#endif // nsShiftJISToUnicode_h__

mercurial