intl/uconv/ucvja/nsJapaneseToUnicode.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; 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 nsShiftJISToUnicode_h__
     6 #define nsShiftJISToUnicode_h__
     7 #include "nsUCSupport.h"
     8 #include "mozilla/Telemetry.h"
    10 class nsShiftJISToUnicode : public nsBasicDecoderSupport
    11 {
    12 public:
    14  nsShiftJISToUnicode() 
    15      { 
    16          mState=0; mData=0; 
    17      }
    18  virtual ~nsShiftJISToUnicode() {}
    20  NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    21      char16_t * aDest, int32_t * aDestLength) ;
    22  NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
    23      int32_t * aDestLength) 
    24      {
    25         *aDestLength = aSrcLength;
    26         return NS_OK;
    27      }
    28  NS_IMETHOD Reset()
    29      {
    30         mState = 0;
    31         return NS_OK;
    32      }
    34   virtual char16_t GetCharacterForUnMapped();
    36 private:
    38 private:
    39  int32_t  mState;
    40  int32_t mData;
    41 };
    43 class nsEUCJPToUnicodeV2 : public nsBasicDecoderSupport
    44 {
    45 public:
    47  nsEUCJPToUnicodeV2() 
    48      { 
    49           mState=0; mData=0; 
    50      }
    51  virtual ~nsEUCJPToUnicodeV2() {}
    53  NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    54      char16_t * aDest, int32_t * aDestLength) ;
    55  NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
    56      int32_t * aDestLength) 
    57      {
    58         *aDestLength = aSrcLength;
    59         return NS_OK;
    60      }
    61  NS_IMETHOD Reset()
    62      {
    63         mState = 0;
    64         return NS_OK;
    65      }
    67 private:
    68  int32_t  mState;
    69  int32_t mData;
    70 };
    72 class nsISO2022JPToUnicodeV2 : public nsBasicDecoderSupport
    73 {
    74 public:
    76  nsISO2022JPToUnicodeV2() 
    77      { 
    78         mState = mState_ASCII;
    79         mLastLegalState = mState_ASCII;
    80         mData = 0;
    81         mRunLength = 0;
    82         G2charset = G2_unknown;
    83         mGB2312Decoder = nullptr;
    84         mEUCKRDecoder = nullptr;
    85         mISO88597Decoder = nullptr;
    86         mozilla::Telemetry::Accumulate(
    87           mozilla::Telemetry::DECODER_INSTANTIATED_ISO2022JP, true);
    88      }
    89  virtual ~nsISO2022JPToUnicodeV2()
    90      {
    91         NS_IF_RELEASE(mGB2312Decoder);
    92         NS_IF_RELEASE(mEUCKRDecoder);
    93         NS_IF_RELEASE(mISO88597Decoder);
    94      }
    96  NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    97      char16_t * aDest, int32_t * aDestLength) ;
    98  NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
    99      int32_t * aDestLength) 
   100      {
   101         *aDestLength = aSrcLength;
   102         return NS_OK;
   103      }
   104  NS_IMETHOD Reset()
   105      {
   106         mState = mState_ASCII;
   107         mLastLegalState = mState_ASCII;
   108         mRunLength = 0;
   109         return NS_OK;
   110      }
   112 private:
   113  enum {
   114    mState_ASCII,
   115    mState_ESC,
   116    mState_ESC_28,
   117    mState_ESC_24,
   118    mState_ESC_24_28,
   119    mState_JISX0201_1976Roman,
   120    mState_JISX0201_1976Kana,
   121    mState_JISX0208_1978,
   122    mState_GB2312_1980,
   123    mState_JISX0208_1983,
   124    mState_KSC5601_1987,
   125    mState_JISX0212_1990,
   126    mState_JISX0208_1978_2ndbyte,
   127    mState_GB2312_1980_2ndbyte,
   128    mState_JISX0208_1983_2ndbyte,
   129    mState_KSC5601_1987_2ndbyte,
   130    mState_JISX0212_1990_2ndbyte,
   131    mState_ESC_2e,
   132    mState_ESC_4e,
   133    mState_ERROR
   134  } mState, mLastLegalState;
   135  int32_t mData;
   136  int32_t mRunLength; // the length of a non-ASCII run
   137  enum {
   138    G2_unknown,
   139    G2_ISO88591,
   140    G2_ISO88597
   141  } G2charset;
   142  nsIUnicodeDecoder *mGB2312Decoder;
   143  nsIUnicodeDecoder *mEUCKRDecoder;
   144  nsIUnicodeDecoder *mISO88597Decoder;
   145 };
   146 #endif // nsShiftJISToUnicode_h__

mercurial