DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (777e60ca8853)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef nsShiftJISToUnicode_h__
#define nsShiftJISToUnicode_h__
#include "nsUCSupport.h"
#include "mozilla/Telemetry.h"

class nsShiftJISToUnicode : public nsBasicDecoderSupport
{
public:

 nsShiftJISToUnicode() 
     { 
         mState=0; mData=0; 
     }
 virtual ~nsShiftJISToUnicode() {}

 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
     char16_t * aDest, int32_t * aDestLength) ;
 NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
     int32_t * aDestLength) 
     {
        *aDestLength = aSrcLength;
        return NS_OK;
     }
 NS_IMETHOD Reset()
     {
        mState = 0;
        return NS_OK;
     }

  virtual char16_t GetCharacterForUnMapped();

private:

private:
 int32_t  mState;
 int32_t mData;
};

class nsEUCJPToUnicodeV2 : public nsBasicDecoderSupport
{
public:

 nsEUCJPToUnicodeV2() 
     { 
          mState=0; mData=0; 
     }
 virtual ~nsEUCJPToUnicodeV2() {}

 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
     char16_t * aDest, int32_t * aDestLength) ;
 NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
     int32_t * aDestLength) 
     {
        *aDestLength = aSrcLength;
        return NS_OK;
     }
 NS_IMETHOD Reset()
     {
        mState = 0;
        return NS_OK;
     }

private:
 int32_t  mState;
 int32_t mData;
};
 
class nsISO2022JPToUnicodeV2 : public nsBasicDecoderSupport
{
public:

 nsISO2022JPToUnicodeV2() 
     { 
        mState = mState_ASCII;
        mLastLegalState = mState_ASCII;
        mData = 0;
        mRunLength = 0;
        G2charset = G2_unknown;
        mGB2312Decoder = nullptr;
        mEUCKRDecoder = nullptr;
        mISO88597Decoder = nullptr;
        mozilla::Telemetry::Accumulate(
          mozilla::Telemetry::DECODER_INSTANTIATED_ISO2022JP, true);
     }
 virtual ~nsISO2022JPToUnicodeV2()
     {
        NS_IF_RELEASE(mGB2312Decoder);
        NS_IF_RELEASE(mEUCKRDecoder);
        NS_IF_RELEASE(mISO88597Decoder);
     }

 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
     char16_t * aDest, int32_t * aDestLength) ;
 NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
     int32_t * aDestLength) 
     {
        *aDestLength = aSrcLength;
        return NS_OK;
     }
 NS_IMETHOD Reset()
     {
        mState = mState_ASCII;
        mLastLegalState = mState_ASCII;
        mRunLength = 0;
        return NS_OK;
     }

private:
 enum {
   mState_ASCII,
   mState_ESC,
   mState_ESC_28,
   mState_ESC_24,
   mState_ESC_24_28,
   mState_JISX0201_1976Roman,
   mState_JISX0201_1976Kana,
   mState_JISX0208_1978,
   mState_GB2312_1980,
   mState_JISX0208_1983,
   mState_KSC5601_1987,
   mState_JISX0212_1990,
   mState_JISX0208_1978_2ndbyte,
   mState_GB2312_1980_2ndbyte,
   mState_JISX0208_1983_2ndbyte,
   mState_KSC5601_1987_2ndbyte,
   mState_JISX0212_1990_2ndbyte,
   mState_ESC_2e,
   mState_ESC_4e,
   mState_ERROR
 } mState, mLastLegalState;
 int32_t mData;
 int32_t mRunLength; // the length of a non-ASCII run
 enum {
   G2_unknown,
   G2_ISO88591,
   G2_ISO88597
 } G2charset;
 nsIUnicodeDecoder *mGB2312Decoder;
 nsIUnicodeDecoder *mEUCKRDecoder;
 nsIUnicodeDecoder *mISO88597Decoder;
};
#endif // nsShiftJISToUnicode_h__