intl/uconv/ucvlatin/nsUTF16ToUnicode.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.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsUTF16ToUnicode_h_
michael@0 7 #define nsUTF16ToUnicode_h_
michael@0 8
michael@0 9 #include "nsISupports.h"
michael@0 10 #include "nsUCSupport.h"
michael@0 11
michael@0 12 // internal base class
michael@0 13 class nsUTF16ToUnicodeBase : public nsBasicDecoderSupport
michael@0 14 {
michael@0 15 protected:
michael@0 16 // ctor accessible only by child classes
michael@0 17 nsUTF16ToUnicodeBase() { Reset();}
michael@0 18
michael@0 19 nsresult UTF16ConvertToUnicode(const char * aSrc,
michael@0 20 int32_t * aSrcLength, char16_t * aDest,
michael@0 21 int32_t * aDestLength, bool aSwapBytes);
michael@0 22
michael@0 23 public:
michael@0 24 //--------------------------------------------------------------------
michael@0 25 // Subclassing of nsDecoderSupport class [declaration]
michael@0 26
michael@0 27 NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
michael@0 28 int32_t * aDestLength);
michael@0 29 NS_IMETHOD Reset();
michael@0 30
michael@0 31 protected:
michael@0 32 uint8_t mState;
michael@0 33 // to store an odd byte left over between runs
michael@0 34 uint8_t mOddByte;
michael@0 35 // to store an odd high surrogate left over between runs
michael@0 36 char16_t mOddHighSurrogate;
michael@0 37 // to store an odd low surrogate left over between runs
michael@0 38 char16_t mOddLowSurrogate;
michael@0 39 };
michael@0 40
michael@0 41 // UTF-16 big endian
michael@0 42 class nsUTF16BEToUnicode : public nsUTF16ToUnicodeBase
michael@0 43 {
michael@0 44 public:
michael@0 45
michael@0 46 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
michael@0 47 char16_t * aDest, int32_t * aDestLength);
michael@0 48 };
michael@0 49
michael@0 50 // UTF-16 little endian
michael@0 51 class nsUTF16LEToUnicode : public nsUTF16ToUnicodeBase
michael@0 52 {
michael@0 53 public:
michael@0 54
michael@0 55 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
michael@0 56 char16_t * aDest, int32_t * aDestLength);
michael@0 57 };
michael@0 58
michael@0 59 // UTF-16 with BOM
michael@0 60 class nsUTF16ToUnicode : public nsUTF16ToUnicodeBase
michael@0 61 {
michael@0 62 public:
michael@0 63
michael@0 64 nsUTF16ToUnicode() { Reset();}
michael@0 65 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
michael@0 66 char16_t * aDest, int32_t * aDestLength);
michael@0 67
michael@0 68 NS_IMETHOD Reset();
michael@0 69
michael@0 70 private:
michael@0 71
michael@0 72 enum Endian {kUnknown, kBigEndian, kLittleEndian};
michael@0 73 Endian mEndian;
michael@0 74 bool mFoundBOM;
michael@0 75 };
michael@0 76
michael@0 77 #endif /* nsUTF16ToUnicode_h_ */

mercurial