michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsUnicodeToUTF16_h_ michael@0: #define nsUnicodeToUTF16_h_ michael@0: michael@0: #include "nsUCSupport.h" michael@0: #include "mozilla/Endian.h" michael@0: michael@0: class nsUnicodeToUTF16BE: public nsBasicEncoder michael@0: { michael@0: public: michael@0: nsUnicodeToUTF16BE() { mBOM = 0;} michael@0: michael@0: //-------------------------------------------------------------------- michael@0: // Interface nsIUnicodeEncoder [declaration] michael@0: michael@0: NS_IMETHOD Convert(const char16_t * aSrc, int32_t * aSrcLength, michael@0: char * aDest, int32_t * aDestLength); michael@0: NS_IMETHOD GetMaxLength(const char16_t * aSrc, int32_t aSrcLength, michael@0: int32_t * aDestLength); michael@0: NS_IMETHOD Finish(char * aDest, int32_t * aDestLength); michael@0: NS_IMETHOD Reset(); michael@0: NS_IMETHOD SetOutputErrorBehavior(int32_t aBehavior, michael@0: nsIUnicharEncoder * aEncoder, char16_t aChar); michael@0: michael@0: protected: michael@0: char16_t mBOM; michael@0: NS_IMETHOD CopyData(char* aDest, const char16_t* aSrc, int32_t aLen ); michael@0: }; michael@0: michael@0: class nsUnicodeToUTF16LE: public nsUnicodeToUTF16BE michael@0: { michael@0: public: michael@0: nsUnicodeToUTF16LE() { mBOM = 0;} michael@0: michael@0: protected: michael@0: NS_IMETHOD CopyData(char* aDest, const char16_t* aSrc, int32_t aLen ); michael@0: }; michael@0: michael@0: #if MOZ_LITTLE_ENDIAN michael@0: class nsUnicodeToUTF16: public nsUnicodeToUTF16LE michael@0: #else michael@0: class nsUnicodeToUTF16: public nsUnicodeToUTF16BE michael@0: #endif michael@0: { michael@0: public: michael@0: nsUnicodeToUTF16() { mBOM = 0xFEFF;} michael@0: }; michael@0: michael@0: #endif /* nsUnicodeToUTF16_h_ */