intl/uconv/ucvko/nsISO2022KRToUnicode.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/uconv/ucvko/nsISO2022KRToUnicode.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/* -*- Mode: C; tab-width: 4; 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 nsISO2022KRToUnicode_h__
     1.9 +#define nsISO2022KRToUnicode_h__
    1.10 +#include "nsUCSupport.h"
    1.11 +#include "mozilla/Telemetry.h"
    1.12 +
    1.13 +class nsISO2022KRToUnicode : public nsBasicDecoderSupport
    1.14 +{
    1.15 +public:
    1.16 +  nsISO2022KRToUnicode()
    1.17 +  { 
    1.18 +    mState = mState_Init;
    1.19 +    mLastLegalState = mState_ASCII;
    1.20 +    mData = 0;
    1.21 +    mEUCKRDecoder = nullptr;
    1.22 +    mRunLength = 0;
    1.23 +    mozilla::Telemetry::Accumulate(
    1.24 +      mozilla::Telemetry::DECODER_INSTANTIATED_ISO2022KR, true);
    1.25 +  }
    1.26 +
    1.27 +  virtual ~nsISO2022KRToUnicode()
    1.28 +  {
    1.29 +    NS_IF_RELEASE(mEUCKRDecoder);
    1.30 +  }
    1.31 +
    1.32 +  NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    1.33 +     char16_t * aDest, int32_t * aDestLength) ;
    1.34 +  
    1.35 +  NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
    1.36 +     int32_t * aDestLength) 
    1.37 +  {
    1.38 +    *aDestLength = aSrcLength;
    1.39 +    return NS_OK;
    1.40 +  }
    1.41 +
    1.42 +  NS_IMETHOD Reset()
    1.43 +  {
    1.44 +    mState = mState_Init;
    1.45 +    mLastLegalState = mState_ASCII;
    1.46 +    mRunLength = 0;
    1.47 +    return NS_OK;
    1.48 +  }
    1.49 +
    1.50 +private:
    1.51 +  enum {
    1.52 +    mState_Init,
    1.53 +    mState_ASCII,
    1.54 +    mState_ESC,
    1.55 +    mState_ESC_24,
    1.56 +    mState_ESC_24_29,
    1.57 +    mState_KSX1001_1992,
    1.58 +    mState_KSX1001_1992_2ndbyte,
    1.59 +    mState_ERROR
    1.60 +  } mState, mLastLegalState;
    1.61 +
    1.62 +  uint8_t mData;
    1.63 +
    1.64 +  // Length of non-ASCII run
    1.65 +  uint32_t mRunLength;
    1.66 +
    1.67 +  nsIUnicodeDecoder *mEUCKRDecoder;
    1.68 +};
    1.69 +#endif // nsISO2022KRToUnicode_h__

mercurial