コード例 #1
0
ファイル: CP949.cs プロジェクト: pmq20/mono_forked
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetByteCountImpl(char *chars, int count)
        {
            int         index   = 0;
            int         length  = 0;
            int         end     = count;
            DbcsConvert convert = GetConvert();

            // 00 00 - FF FF
            for (int i = 0; i < end; i++, charCount--)
            {
                char c = chars[i];
                if (c <= 0x80 || c == 0xFF)   // ASCII
                {
                    length++;
                    continue;
                }
                byte b1 = convert.u2n[((int)c) * 2];
                byte b2 = convert.u2n[((int)c) * 2 + 1];
                if (b1 == 0 && b2 == 0)
                {
#if NET_2_0
                    // FIXME: handle fallback for GetByteCountImpl().
                    length++;
#else
                    length++;
#endif
                }
                else
                {
                    length += 2;
                }
            }
            return(length);
        }
コード例 #2
0
        // Get the bytes that result from encoding a character buffer.
        public override int GetByteCount(char[] chars, int index, int count)
        {
            int         length  = 0;
            DbcsConvert convert = GetConvert();

            // 00 00 - FF FF
            while (count-- > 0)
            {
                char c = chars[index++];
                if (c <= 0x80 || c == 0xFF)
                {                 // ASCII
                    length++;
                    continue;
                }
                byte b1 = convert.u2n[((int)c) * 2];
                byte b2 = convert.u2n[((int)c) * 2 + 1];
                if (b1 == 0 && b2 == 0)
                {
#if NET_2_0
                    // FIXME: handle fallback for GetByteCountImpl().
                    length++;
#else
                    length++;
#endif
                }
                else
                {
                    length += 2;
                }
            }
            return(length);
        }
コード例 #3
0
ファイル: CP936.cs プロジェクト: robert-j/mono-fork
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetByteCountImpl(
            char *chars, int count)
        {
            DbcsConvert gb2312 = GetConvert();
            int         index  = 0;
            int         length = 0;

            while (count-- > 0)
            {
                char c = chars[index++];
                if (c <= 0x80 || c == 0xFF)                   // ASCII
                {
                    length++;
                    continue;
                }
                byte b1 = gb2312.u2n[((int)c) * 2 + 1];
                byte b2 = gb2312.u2n[((int)c) * 2];
                if (b1 == 0 && b2 == 0)
                {
#if NET_2_0
                    // FIXME: handle fallback for GetByteCount().
#else
                    length++;
#endif
                }
                else
                {
                    length += 2;
                }
            }
            return(length);
        }
コード例 #4
0
ファイル: CP950.cs プロジェクト: samcf111/unityMono5.5.0
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            DbcsConvert           convert   = GetConvert();
            int                   charIndex = 0;
            int                   byteIndex = 0;
            int                   end       = charCount;
            EncoderFallbackBuffer buffer    = null;

            int origIndex = byteIndex;

            for (int i = charIndex; i < end; i++, charCount--)
            {
                char c = chars[i];
                if (c <= 0x80 || c == 0xFF)                   // ASCII
                {
                    bytes[byteIndex++] = (byte)c;
                    continue;
                }
                byte b1 = convert.u2n[((int)c) * 2 + 1];
                byte b2 = convert.u2n[((int)c) * 2];
                if (b1 == 0 && b2 == 0)
                {
                    HandleFallback(ref buffer, chars,
                                   ref i, ref charCount,
                                   bytes, ref byteIndex, ref byteCount, null);
                }
                else
                {
                    bytes[byteIndex++] = b1;
                    bytes[byteIndex++] = b2;
                }
            }
            return(byteIndex - origIndex);
        }
コード例 #5
0
        // Get the bytes that result from encoding a character buffer.
        public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
        {
            int byteCount = bytes.Length;
            int end       = charIndex + charCount;

            DbcsConvert           convert = GetConvert();
            EncoderFallbackBuffer buffer  = null;

            // 00 00 - FF FF
            int origIndex = byteIndex;

            for (int i = charIndex; i < end; i++, charCount--)
            {
                char c = chars[i];
                if (c <= 0x80 || c == 0xFF)
                {                 // ASCII
                    bytes[byteIndex++] = (byte)c;
                    continue;
                }
                byte b1 = convert.u2n[((int)c) * 2];
                byte b2 = convert.u2n[((int)c) * 2 + 1];
                if (b1 == 0 && b2 == 0)
                {
                    HandleFallback(ref buffer, chars, ref i, ref charCount,
                                   bytes, ref byteIndex, ref byteCount, null);
                }
                else
                {
                    bytes[byteIndex++] = b1;
                    bytes[byteIndex++] = b2;
                }
            }
            return(byteIndex - origIndex);
        }
コード例 #6
0
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetBytesImpl(char *chars, int charCount, byte *bytes, int byteCount)
        {
            DbcsConvert gb2312    = GetConvert();
            int         charIndex = 0;
            int         byteIndex = 0;
            int         end       = charCount;

#if NET_2_0
            EncoderFallbackBuffer buffer = null;
#endif

            int origIndex = byteIndex;
            for (int i = charIndex; i < end; i++, charCount--)
            {
                char c = chars[i];
                if (c <= 0x80 || c == 0xFF)                   // ASCII
                {
                    int offset = byteIndex++;
                    if (bytes != null)
                    {
                        bytes[offset] = (byte)c;
                    }
                    continue;
                }
                byte b1 = gb2312.u2n[((int)c) * 2 + 1];
                byte b2 = gb2312.u2n[((int)c) * 2];
                if (b1 == 0 && b2 == 0)
                {
#if NET_2_0
                    HandleFallback(ref buffer, chars,
                                   ref i, ref charCount,
                                   bytes, ref byteIndex, ref byteCount, null);
#else
                    int offset = byteIndex++;
                    if (bytes != null)
                    {
                        bytes[offset] = (byte)'?';
                    }
#endif
                }
                else
                {
                    if (bytes != null)
                    {
                        bytes[byteIndex++] = b1;
                        bytes[byteIndex++] = b2;
                    }
                    else
                    {
                        byteIndex += 2;
                    }
                }
            }
            return(byteIndex - origIndex);
        }
コード例 #7
0
        protected int GetBytesInternal(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
        {
            int origIndex = byteIndex;
            int end       = charIndex + charCount;
            int byteCount = bytes != null ? bytes.Length : 0;

            DbcsConvert gb2312 = GetConvert();

#if NET_2_0
            EncoderFallbackBuffer buffer = null;
#endif
            for (int i = charIndex; i < end; i++, charCount--)
            {
                char c = chars[i];
                if (c <= 0x80 || c == 0xFF)
                {                 // ASCII
                    int offset = byteIndex++;
                    if (bytes != null)
                    {
                        bytes[offset] = (byte)c;
                    }
                    continue;
                }
                byte b1 = gb2312.u2n[((int)c) * 2 + 1];
                byte b2 = gb2312.u2n[((int)c) * 2];
                if (b1 == 0 && b2 == 0)
                {
#if NET_2_0
                    HandleFallback(ref buffer, chars, ref i, ref charCount,
                                   bytes, ref byteIndex, ref byteCount, null);
#else
                    int offset = byteIndex++;
                    if (bytes != null)
                    {
                        bytes[] = (byte)'?';
                    }
#endif
                }
                else
                {
                    if (bytes != null)
                    {
                        bytes[byteIndex++] = b1;
                        bytes[byteIndex++] = b2;
                    }
                    else
                    {
                        byteIndex += 2;
                    }
                }
            }
            return(byteIndex - origIndex);
        }
コード例 #8
0
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int         charIndex = 0;
            int         byteIndex = 0;
            DbcsConvert convert   = GetConvert();

#if NET_2_0
            EncoderFallbackBuffer buffer = null;
#endif

            // 00 00 - FF FF
            int origIndex = byteIndex;
            while (charCount-- > 0)
            {
                char c = chars[charIndex++];
                if (c <= 0x80 || c == 0xFF)   // ASCII
                {
                    bytes[byteIndex++] = (byte)c;
                    continue;
                }
                byte b1 = convert.u2n[((int)c) * 2];
                byte b2 = convert.u2n[((int)c) * 2 + 1];
                if (b1 == 0 && b2 == 0)
                {
#if NET_2_0
                    HandleFallback(ref buffer, chars, ref charIndex, ref charCount,
                                   bytes, ref byteIndex, ref byteCount, null);
#else
                    bytes[byteIndex++] = (byte)'?';
#endif
                }
                else
                {
                    bytes[byteIndex++] = b1;
                    bytes[byteIndex++] = b2;
                }
            }
            return(byteIndex - origIndex);
        }
コード例 #9
0
ファイル: CP936.cs プロジェクト: robert-j/mono-fork
        // Get the bytes that result from encoding a character buffer.
        public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
        {
            int byteCount = bytes.Length;

            DbcsConvert gb2312 = GetConvert();

#if NET_2_0
            EncoderFallbackBuffer buffer = null;
#endif

            int origIndex = byteIndex;
            while (charCount-- > 0)
            {
                char c = chars[charIndex++];
                if (c <= 0x80 || c == 0xFF)
                {                 // ASCII
                    bytes[byteIndex++] = (byte)c;
                    continue;
                }
                byte b1 = gb2312.u2n[((int)c) * 2 + 1];
                byte b2 = gb2312.u2n[((int)c) * 2];
                if (b1 == 0 && b2 == 0)
                {
#if NET_2_0
                    HandleFallback(ref buffer, chars, ref charIndex, ref charCount,
                                   bytes, ref byteIndex, ref byteCount, null);
#else
                    bytes[byteIndex++] = (byte)'?';
#endif
                }
                else
                {
                    bytes[byteIndex++] = b1;
                    bytes[byteIndex++] = b2;
                }
            }
            return(byteIndex - origIndex);
        }
コード例 #10
0
ファイル: CP949.cs プロジェクト: KonajuGames/SharpLang
 // Constructor.
 public KoreanDecoder (DbcsConvert convert, bool useUHC)
     : base(convert)
 {
     this.useUHC = useUHC;
 }
コード例 #11
0
 // Constructor.
 public KoreanDecoder(DbcsConvert convert, bool useUHC)
     : base(convert)
 {
     this.useUHC = useUHC;
 }
コード例 #12
0
ファイル: CP936.cs プロジェクト: robert-j/mono-fork
 // Constructor.
 public CP936Decoder(DbcsConvert convert)
     : base(convert)
 {
 }
コード例 #13
0
ファイル: DbcsEncoding.cs プロジェクト: KonajuGames/SharpLang
			// Constructor.
			public DbcsDecoder(DbcsConvert convert)
			{
				this.convert = convert;
			}
コード例 #14
0
 // Constructor.
 public DbcsDecoder(DbcsConvert convert)
 {
     this.convert = convert;
 }
コード例 #15
0
ファイル: CP936.cs プロジェクト: nlhepler/mono
		// Constructor.
		public CP936Decoder (DbcsConvert convert)
			: base (convert)
		{
		}