intl/uconv/ucvlatin/nsUTF16ToUnicode.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     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/. */
     6 #ifndef nsUTF16ToUnicode_h_
     7 #define nsUTF16ToUnicode_h_
     9 #include "nsISupports.h"
    10 #include "nsUCSupport.h"
    12 // internal base class
    13 class nsUTF16ToUnicodeBase : public nsBasicDecoderSupport
    14 {
    15 protected:
    16   // ctor accessible only by child classes
    17   nsUTF16ToUnicodeBase() { Reset();}
    19   nsresult UTF16ConvertToUnicode(const char * aSrc,
    20                                  int32_t * aSrcLength, char16_t * aDest,
    21                                  int32_t * aDestLength, bool aSwapBytes);
    23 public: 
    24   //--------------------------------------------------------------------
    25   // Subclassing of nsDecoderSupport class [declaration]
    27   NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength, 
    28       int32_t * aDestLength);
    29   NS_IMETHOD Reset();
    31 protected:
    32   uint8_t mState;
    33   // to store an odd byte left over between runs
    34   uint8_t mOddByte;
    35   // to store an odd high surrogate left over between runs
    36   char16_t mOddHighSurrogate;
    37   // to store an odd low surrogate left over between runs
    38   char16_t mOddLowSurrogate;
    39 };
    41 // UTF-16 big endian
    42 class nsUTF16BEToUnicode : public nsUTF16ToUnicodeBase
    43 {
    44 public:
    46   NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    47       char16_t * aDest, int32_t * aDestLength); 
    48 };
    50 // UTF-16 little endian
    51 class nsUTF16LEToUnicode : public nsUTF16ToUnicodeBase
    52 {
    53 public:
    55   NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    56       char16_t * aDest, int32_t * aDestLength); 
    57 };
    59 // UTF-16 with BOM
    60 class nsUTF16ToUnicode : public nsUTF16ToUnicodeBase
    61 {
    62 public:
    64   nsUTF16ToUnicode() { Reset();}
    65   NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
    66       char16_t * aDest, int32_t * aDestLength); 
    68   NS_IMETHOD Reset();
    70 private:
    72   enum Endian {kUnknown, kBigEndian, kLittleEndian};
    73   Endian  mEndian; 
    74   bool    mFoundBOM;
    75 };
    77 #endif /* nsUTF16ToUnicode_h_ */

mercurial