コード例 #1
0
		public unsafe void HandleFallback (ref EncoderFallbackBuffer buffer,
		                                   char* chars, ref int charIndex, ref int charCount,
		                                   byte* bytes, ref int byteIndex, ref int byteCount, object state)
		{
			if (buffer == null)
				buffer = EncoderFallback.CreateFallbackBuffer ();

			if (charCount > 1 && (Char.IsSurrogate (chars [charIndex]) && Char.IsSurrogate (chars [charIndex + 1]))) {
				buffer.Fallback (chars [charIndex], chars [charIndex + 1], charIndex);
				charIndex++;
				charCount--;
			} else {
				buffer.Fallback (chars [charIndex], charIndex);
			}

			char[] tmp = new char [buffer.Remaining];
			int idx = 0;
			while (buffer.Remaining > 0)
				tmp [idx++] = buffer.GetNextChar ();

			fixed (char* tmparr = tmp) {
				var outbytes = bytes == null ? null : bytes + byteIndex;
				var len = state == null ?
					GetBytes (tmparr, tmp.Length, outbytes, byteCount)
					: GetBytesInternal (tmparr, tmp.Length, outbytes, byteCount, true, state);

				byteIndex += len;
				byteCount -= len;
			}
		}
コード例 #2
0
		public unsafe void HandleFallback (ref EncoderFallbackBuffer buffer,
		                                   char* chars, ref int charIndex, ref int charCount,
		                                   byte* bytes, ref int byteIndex, ref int byteCount)
		{
			HandleFallback (ref buffer, chars, ref charIndex, ref charCount,
				bytes, ref byteIndex, ref byteCount, null);
		}
コード例 #3
0
		int GetBytes (char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, ref EncoderFallbackBuffer buffer, ref char[] fallback_chars)
		{
			if (chars == null)
				throw new ArgumentNullException ("chars");

			unsafe {
				fixed (char *cptr = chars) {
					return InternalGetBytes (cptr, chars.Length, charIndex, charCount, bytes, byteIndex, ref buffer, ref fallback_chars);
				}
			}
		}
コード例 #4
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 161)
                {
                    switch (ch)
                    {
                    case 0x00A4:
                    case 0x00A7:
                    case 0x00A8:
                    case 0x00AD:
                    case 0x00AF:
                    case 0x00B0:
                    case 0x00B4:
                    case 0x00B8:
                    case 0x00C1:
                    case 0x00C2:
                    case 0x00C3:
                    case 0x00C4:
                    case 0x00C5:
                    case 0x00C6:
                    case 0x00C9:
                    case 0x00CB:
                    case 0x00CD:
                    case 0x00CE:
                    case 0x00D4:
                    case 0x00D5:
                    case 0x00D6:
                    case 0x00D7:
                    case 0x00D8:
                    case 0x00DA:
                    case 0x00DB:
                    case 0x00DC:
                    case 0x00DF:
                    case 0x00E1:
                    case 0x00E2:
                    case 0x00E3:
                    case 0x00E4:
                    case 0x00E5:
                    case 0x00E6:
                    case 0x00E9:
                    case 0x00EB:
                    case 0x00ED:
                    case 0x00EE:
                    case 0x00F4:
                    case 0x00F5:
                    case 0x00F6:
                    case 0x00F7:
                    case 0x00F8:
                    case 0x00FA:
                    case 0x00FB:
                    case 0x00FC:
                        break;

                    case 0x0100:
                        ch = 0xC0;
                        break;

                    case 0x0101:
                        ch = 0xE0;
                        break;

                    case 0x0104:
                        ch = 0xA1;
                        break;

                    case 0x0105:
                        ch = 0xB1;
                        break;

                    case 0x010C:
                        ch = 0xC8;
                        break;

                    case 0x010D:
                        ch = 0xE8;
                        break;

                    case 0x0110:
                        ch = 0xD0;
                        break;

                    case 0x0111:
                        ch = 0xF0;
                        break;

                    case 0x0112:
                        ch = 0xAA;
                        break;

                    case 0x0113:
                        ch = 0xBA;
                        break;

                    case 0x0116:
                        ch = 0xCC;
                        break;

                    case 0x0117:
                        ch = 0xEC;
                        break;

                    case 0x0118:
                        ch = 0xCA;
                        break;

                    case 0x0119:
                        ch = 0xEA;
                        break;

                    case 0x0122:
                        ch = 0xAB;
                        break;

                    case 0x0123:
                        ch = 0xBB;
                        break;

                    case 0x0128:
                        ch = 0xA5;
                        break;

                    case 0x0129:
                        ch = 0xB5;
                        break;

                    case 0x012A:
                        ch = 0xCF;
                        break;

                    case 0x012B:
                        ch = 0xEF;
                        break;

                    case 0x012E:
                        ch = 0xC7;
                        break;

                    case 0x012F:
                        ch = 0xE7;
                        break;

                    case 0x0136:
                        ch = 0xD3;
                        break;

                    case 0x0137:
                        ch = 0xF3;
                        break;

                    case 0x0138:
                        ch = 0xA2;
                        break;

                    case 0x013B:
                        ch = 0xA6;
                        break;

                    case 0x013C:
                        ch = 0xB6;
                        break;

                    case 0x0145:
                        ch = 0xD1;
                        break;

                    case 0x0146:
                        ch = 0xF1;
                        break;

                    case 0x014A:
                        ch = 0xBD;
                        break;

                    case 0x014B:
                        ch = 0xBF;
                        break;

                    case 0x014C:
                        ch = 0xD2;
                        break;

                    case 0x014D:
                        ch = 0xF2;
                        break;

                    case 0x0156:
                        ch = 0xA3;
                        break;

                    case 0x0157:
                        ch = 0xB3;
                        break;

                    case 0x0160:
                        ch = 0xA9;
                        break;

                    case 0x0161:
                        ch = 0xB9;
                        break;

                    case 0x0166:
                        ch = 0xAC;
                        break;

                    case 0x0167:
                        ch = 0xBC;
                        break;

                    case 0x0168:
                        ch = 0xDD;
                        break;

                    case 0x0169:
                        ch = 0xFD;
                        break;

                    case 0x016A:
                        ch = 0xDE;
                        break;

                    case 0x016B:
                        ch = 0xFE;
                        break;

                    case 0x0172:
                        ch = 0xD9;
                        break;

                    case 0x0173:
                        ch = 0xF9;
                        break;

                    case 0x017D:
                        ch = 0xAE;
                        break;

                    case 0x017E:
                        ch = 0xBE;
                        break;

                    case 0x02C7:
                        ch = 0xB7;
                        break;

                    case 0x02D9:
                        ch = 0xFF;
                        break;

                    case 0x02DB:
                        ch = 0xB2;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #5
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 26)
                {
                    switch (ch)
                    {
                    case 0x001B:
                    case 0x001D:
                    case 0x001E:
                    case 0x001F:
                    case 0x0020:
                    case 0x0021:
                    case 0x0022:
                    case 0x0023:
                    case 0x0024:
                    case 0x0025:
                    case 0x0026:
                    case 0x0027:
                    case 0x0028:
                    case 0x0029:
                    case 0x002A:
                    case 0x002B:
                    case 0x002C:
                    case 0x002D:
                    case 0x002E:
                    case 0x002F:
                    case 0x0030:
                    case 0x0031:
                    case 0x0032:
                    case 0x0033:
                    case 0x0034:
                    case 0x0035:
                    case 0x0036:
                    case 0x0037:
                    case 0x0038:
                    case 0x0039:
                    case 0x003A:
                    case 0x003B:
                    case 0x003C:
                    case 0x003D:
                    case 0x003E:
                    case 0x003F:
                    case 0x0040:
                    case 0x0041:
                    case 0x0042:
                    case 0x0043:
                    case 0x0044:
                    case 0x0045:
                    case 0x0046:
                    case 0x0047:
                    case 0x0048:
                    case 0x0049:
                    case 0x004A:
                    case 0x004B:
                    case 0x004C:
                    case 0x004D:
                    case 0x004E:
                    case 0x004F:
                    case 0x0050:
                    case 0x0051:
                    case 0x0052:
                    case 0x0053:
                    case 0x0054:
                    case 0x0055:
                    case 0x0056:
                    case 0x0057:
                    case 0x0058:
                    case 0x0059:
                    case 0x005A:
                    case 0x005B:
                    case 0x005C:
                    case 0x005D:
                    case 0x005E:
                    case 0x005F:
                    case 0x0060:
                    case 0x0061:
                    case 0x0062:
                    case 0x0063:
                    case 0x0064:
                    case 0x0065:
                    case 0x0066:
                    case 0x0067:
                    case 0x0068:
                    case 0x0069:
                    case 0x006A:
                    case 0x006B:
                    case 0x006C:
                    case 0x006D:
                    case 0x006E:
                    case 0x006F:
                    case 0x0070:
                    case 0x0071:
                    case 0x0072:
                    case 0x0073:
                    case 0x0074:
                    case 0x0075:
                    case 0x0076:
                    case 0x0077:
                    case 0x0078:
                    case 0x0079:
                    case 0x007A:
                    case 0x007B:
                    case 0x007C:
                    case 0x007D:
                    case 0x007E:
                        break;

                    case 0x001A:
                        ch = 0x7F;
                        break;

                    case 0x001C:
                        ch = 0x1A;
                        break;

                    case 0x007F:
                        ch = 0x1C;
                        break;

                    case 0x00A0:
                        ch = 0xFF;
                        break;

                    case 0x00A4:
                        ch = 0xFD;
                        break;

                    case 0x00A7:
                        ch = 0x15;
                        break;

                    case 0x00B0:
                        ch = 0xF8;
                        break;

                    case 0x00B6:
                        ch = 0x14;
                        break;

                    case 0x00B7:
                        ch = 0xFA;
                        break;

                    case 0x0401:
                        ch = 0xF0;
                        break;

                    case 0x0404:
                        ch = 0xF2;
                        break;

                    case 0x0407:
                        ch = 0xF4;
                        break;

                    case 0x040E:
                        ch = 0xF6;
                        break;

                    case 0x0410:
                    case 0x0411:
                    case 0x0412:
                    case 0x0413:
                    case 0x0414:
                    case 0x0415:
                    case 0x0416:
                    case 0x0417:
                    case 0x0418:
                    case 0x0419:
                    case 0x041A:
                    case 0x041B:
                    case 0x041C:
                    case 0x041D:
                    case 0x041E:
                    case 0x041F:
                    case 0x0420:
                    case 0x0421:
                    case 0x0422:
                    case 0x0423:
                    case 0x0424:
                    case 0x0425:
                    case 0x0426:
                    case 0x0427:
                    case 0x0428:
                    case 0x0429:
                    case 0x042A:
                    case 0x042B:
                    case 0x042C:
                    case 0x042D:
                    case 0x042E:
                    case 0x042F:
                    case 0x0430:
                    case 0x0431:
                    case 0x0432:
                    case 0x0433:
                    case 0x0434:
                    case 0x0435:
                    case 0x0436:
                    case 0x0437:
                    case 0x0438:
                    case 0x0439:
                    case 0x043A:
                    case 0x043B:
                    case 0x043C:
                    case 0x043D:
                    case 0x043E:
                    case 0x043F:
                        ch -= 0x0390;
                        break;

                    case 0x0440:
                    case 0x0441:
                    case 0x0442:
                    case 0x0443:
                    case 0x0444:
                    case 0x0445:
                    case 0x0446:
                    case 0x0447:
                    case 0x0448:
                    case 0x0449:
                    case 0x044A:
                    case 0x044B:
                    case 0x044C:
                    case 0x044D:
                    case 0x044E:
                    case 0x044F:
                        ch -= 0x0360;
                        break;

                    case 0x0451:
                        ch = 0xF1;
                        break;

                    case 0x0454:
                        ch = 0xF3;
                        break;

                    case 0x0457:
                        ch = 0xF5;
                        break;

                    case 0x045E:
                        ch = 0xF7;
                        break;

                    case 0x2022:
                        ch = 0x07;
                        break;

                    case 0x203C:
                        ch = 0x13;
                        break;

                    case 0x2116:
                        ch = 0xFC;
                        break;

                    case 0x2190:
                        ch = 0x1B;
                        break;

                    case 0x2191:
                        ch = 0x18;
                        break;

                    case 0x2192:
                        ch = 0x1A;
                        break;

                    case 0x2193:
                        ch = 0x19;
                        break;

                    case 0x2194:
                        ch = 0x1D;
                        break;

                    case 0x2195:
                        ch = 0x12;
                        break;

                    case 0x21A8:
                        ch = 0x17;
                        break;

                    case 0x2219:
                        ch = 0xF9;
                        break;

                    case 0x221A:
                        ch = 0xFB;
                        break;

                    case 0x221F:
                        ch = 0x1C;
                        break;

                    case 0x2302:
                        ch = 0x7F;
                        break;

                    case 0x2500:
                        ch = 0xC4;
                        break;

                    case 0x2502:
                        ch = 0xB3;
                        break;

                    case 0x250C:
                        ch = 0xDA;
                        break;

                    case 0x2510:
                        ch = 0xBF;
                        break;

                    case 0x2514:
                        ch = 0xC0;
                        break;

                    case 0x2518:
                        ch = 0xD9;
                        break;

                    case 0x251C:
                        ch = 0xC3;
                        break;

                    case 0x2524:
                        ch = 0xB4;
                        break;

                    case 0x252C:
                        ch = 0xC2;
                        break;

                    case 0x2534:
                        ch = 0xC1;
                        break;

                    case 0x253C:
                        ch = 0xC5;
                        break;

                    case 0x2550:
                        ch = 0xCD;
                        break;

                    case 0x2551:
                        ch = 0xBA;
                        break;

                    case 0x2552:
                        ch = 0xD5;
                        break;

                    case 0x2553:
                        ch = 0xD6;
                        break;

                    case 0x2554:
                        ch = 0xC9;
                        break;

                    case 0x2555:
                        ch = 0xB8;
                        break;

                    case 0x2556:
                        ch = 0xB7;
                        break;

                    case 0x2557:
                        ch = 0xBB;
                        break;

                    case 0x2558:
                        ch = 0xD4;
                        break;

                    case 0x2559:
                        ch = 0xD3;
                        break;

                    case 0x255A:
                        ch = 0xC8;
                        break;

                    case 0x255B:
                        ch = 0xBE;
                        break;

                    case 0x255C:
                        ch = 0xBD;
                        break;

                    case 0x255D:
                        ch = 0xBC;
                        break;

                    case 0x255E:
                        ch = 0xC6;
                        break;

                    case 0x255F:
                        ch = 0xC7;
                        break;

                    case 0x2560:
                        ch = 0xCC;
                        break;

                    case 0x2561:
                        ch = 0xB5;
                        break;

                    case 0x2562:
                        ch = 0xB6;
                        break;

                    case 0x2563:
                        ch = 0xB9;
                        break;

                    case 0x2564:
                        ch = 0xD1;
                        break;

                    case 0x2565:
                        ch = 0xD2;
                        break;

                    case 0x2566:
                        ch = 0xCB;
                        break;

                    case 0x2567:
                        ch = 0xCF;
                        break;

                    case 0x2568:
                        ch = 0xD0;
                        break;

                    case 0x2569:
                        ch = 0xCA;
                        break;

                    case 0x256A:
                        ch = 0xD8;
                        break;

                    case 0x256B:
                        ch = 0xD7;
                        break;

                    case 0x256C:
                        ch = 0xCE;
                        break;

                    case 0x2580:
                        ch = 0xDF;
                        break;

                    case 0x2584:
                        ch = 0xDC;
                        break;

                    case 0x2588:
                        ch = 0xDB;
                        break;

                    case 0x258C:
                        ch = 0xDD;
                        break;

                    case 0x2590:
                        ch = 0xDE;
                        break;

                    case 0x2591:
                        ch = 0xB0;
                        break;

                    case 0x2592:
                        ch = 0xB1;
                        break;

                    case 0x2593:
                        ch = 0xB2;
                        break;

                    case 0x25A0:
                        ch = 0xFE;
                        break;

                    case 0x25AC:
                        ch = 0x16;
                        break;

                    case 0x25B2:
                        ch = 0x1E;
                        break;

                    case 0x25BA:
                        ch = 0x10;
                        break;

                    case 0x25BC:
                        ch = 0x1F;
                        break;

                    case 0x25C4:
                        ch = 0x11;
                        break;

                    case 0x25CB:
                        ch = 0x09;
                        break;

                    case 0x25D8:
                        ch = 0x08;
                        break;

                    case 0x25D9:
                        ch = 0x0A;
                        break;

                    case 0x263A:
                        ch = 0x01;
                        break;

                    case 0x263B:
                        ch = 0x02;
                        break;

                    case 0x263C:
                        ch = 0x0F;
                        break;

                    case 0x2640:
                        ch = 0x0C;
                        break;

                    case 0x2642:
                        ch = 0x0B;
                        break;

                    case 0x2660:
                        ch = 0x06;
                        break;

                    case 0x2663:
                        ch = 0x05;
                        break;

                    case 0x2665:
                        ch = 0x03;
                        break;

                    case 0x2666:
                        ch = 0x04;
                        break;

                    case 0x266A:
                        ch = 0x0D;
                        break;

                    case 0x266B:
                        ch = 0x0E;
                        break;

                    case 0xFFE8:
                        ch = 0xB3;
                        break;

                    case 0xFFE9:
                        ch = 0x1B;
                        break;

                    case 0xFFEA:
                        ch = 0x18;
                        break;

                    case 0xFFEB:
                        ch = 0x1A;
                        break;

                    case 0xFFEC:
                        ch = 0x19;
                        break;

                    case 0xFFED:
                        ch = 0xFE;
                        break;

                    case 0xFFEE:
                        ch = 0x09;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #6
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 26)
                {
                    switch (ch)
                    {
                    case 0x001B:
                    case 0x001D:
                    case 0x001E:
                    case 0x001F:
                    case 0x0020:
                    case 0x0021:
                    case 0x0022:
                    case 0x0023:
                    case 0x0024:
                    case 0x0025:
                    case 0x0026:
                    case 0x0027:
                    case 0x0028:
                    case 0x0029:
                    case 0x002A:
                    case 0x002B:
                    case 0x002C:
                    case 0x002D:
                    case 0x002E:
                    case 0x002F:
                    case 0x0030:
                    case 0x0031:
                    case 0x0032:
                    case 0x0033:
                    case 0x0034:
                    case 0x0035:
                    case 0x0036:
                    case 0x0037:
                    case 0x0038:
                    case 0x0039:
                    case 0x003A:
                    case 0x003B:
                    case 0x003C:
                    case 0x003D:
                    case 0x003E:
                    case 0x003F:
                    case 0x0040:
                    case 0x0041:
                    case 0x0042:
                    case 0x0043:
                    case 0x0044:
                    case 0x0045:
                    case 0x0046:
                    case 0x0047:
                    case 0x0048:
                    case 0x0049:
                    case 0x004A:
                    case 0x004B:
                    case 0x004C:
                    case 0x004D:
                    case 0x004E:
                    case 0x004F:
                    case 0x0050:
                    case 0x0051:
                    case 0x0052:
                    case 0x0053:
                    case 0x0054:
                    case 0x0055:
                    case 0x0056:
                    case 0x0057:
                    case 0x0058:
                    case 0x0059:
                    case 0x005A:
                    case 0x005B:
                    case 0x005C:
                    case 0x005D:
                    case 0x005E:
                    case 0x005F:
                    case 0x0060:
                    case 0x0061:
                    case 0x0062:
                    case 0x0063:
                    case 0x0064:
                    case 0x0065:
                    case 0x0066:
                    case 0x0067:
                    case 0x0068:
                    case 0x0069:
                    case 0x006A:
                    case 0x006B:
                    case 0x006C:
                    case 0x006D:
                    case 0x006E:
                    case 0x006F:
                    case 0x0070:
                    case 0x0071:
                    case 0x0072:
                    case 0x0073:
                    case 0x0074:
                    case 0x0075:
                    case 0x0076:
                    case 0x0077:
                    case 0x0078:
                    case 0x0079:
                    case 0x007A:
                    case 0x007B:
                    case 0x007C:
                    case 0x007D:
                    case 0x007E:
                        break;

                    case 0x001A:
                        ch = 0x7F;
                        break;

                    case 0x001C:
                        ch = 0x1A;
                        break;

                    case 0x007F:
                        ch = 0x1C;
                        break;

                    case 0x00A0:
                        ch = 0xFF;
                        break;

                    case 0x00A4:
                        ch = 0xCF;
                        break;

                    case 0x00A7:
                        ch = 0xF5;
                        break;

                    case 0x00A8:
                        ch = 0xF9;
                        break;

                    case 0x00AB:
                        ch = 0xAE;
                        break;

                    case 0x00AD:
                        ch = 0xF0;
                        break;

                    case 0x00B0:
                        ch = 0xF8;
                        break;

                    case 0x00B4:
                        ch = 0xEF;
                        break;

                    case 0x00B6:
                        ch = 0x14;
                        break;

                    case 0x00B8:
                        ch = 0xF7;
                        break;

                    case 0x00BB:
                        ch = 0xAF;
                        break;

                    case 0x00C1:
                        ch = 0xB5;
                        break;

                    case 0x00C2:
                        ch = 0xB6;
                        break;

                    case 0x00C4:
                        ch = 0x8E;
                        break;

                    case 0x00C7:
                        ch = 0x80;
                        break;

                    case 0x00C9:
                        ch = 0x90;
                        break;

                    case 0x00CB:
                        ch = 0xD3;
                        break;

                    case 0x00CD:
                        ch = 0xD6;
                        break;

                    case 0x00CE:
                        ch = 0xD7;
                        break;

                    case 0x00D0:
                        ch = 0xD1;
                        break;

                    case 0x00D3:
                        ch = 0xE0;
                        break;

                    case 0x00D4:
                        ch = 0xE2;
                        break;

                    case 0x00D6:
                        ch = 0x99;
                        break;

                    case 0x00D7:
                        ch = 0x9E;
                        break;

                    case 0x00DA:
                        ch = 0xE9;
                        break;

                    case 0x00DC:
                        ch = 0x9A;
                        break;

                    case 0x00DD:
                        ch = 0xED;
                        break;

                    case 0x00DF:
                        ch = 0xE1;
                        break;

                    case 0x00E1:
                        ch = 0xA0;
                        break;

                    case 0x00E2:
                        ch = 0x83;
                        break;

                    case 0x00E4:
                        ch = 0x84;
                        break;

                    case 0x00E7:
                        ch = 0x87;
                        break;

                    case 0x00E9:
                        ch = 0x82;
                        break;

                    case 0x00EB:
                        ch = 0x89;
                        break;

                    case 0x00ED:
                        ch = 0xA1;
                        break;

                    case 0x00EE:
                        ch = 0x8C;
                        break;

                    case 0x00F3:
                        ch = 0xA2;
                        break;

                    case 0x00F4:
                        ch = 0x93;
                        break;

                    case 0x00F6:
                        ch = 0x94;
                        break;

                    case 0x00F7:
                        ch = 0xF6;
                        break;

                    case 0x00FA:
                        ch = 0xA3;
                        break;

                    case 0x00FC:
                        ch = 0x81;
                        break;

                    case 0x00FD:
                        ch = 0xEC;
                        break;

                    case 0x0102:
                        ch = 0xC6;
                        break;

                    case 0x0103:
                        ch = 0xC7;
                        break;

                    case 0x0104:
                        ch = 0xA4;
                        break;

                    case 0x0105:
                        ch = 0xA5;
                        break;

                    case 0x0106:
                        ch = 0x8F;
                        break;

                    case 0x0107:
                        ch = 0x86;
                        break;

                    case 0x010C:
                        ch = 0xAC;
                        break;

                    case 0x010D:
                        ch = 0x9F;
                        break;

                    case 0x010E:
                        ch = 0xD2;
                        break;

                    case 0x010F:
                        ch = 0xD4;
                        break;

                    case 0x0110:
                        ch = 0xD1;
                        break;

                    case 0x0111:
                        ch = 0xD0;
                        break;

                    case 0x0118:
                        ch = 0xA8;
                        break;

                    case 0x0119:
                        ch = 0xA9;
                        break;

                    case 0x011A:
                        ch = 0xB7;
                        break;

                    case 0x011B:
                        ch = 0xD8;
                        break;

                    case 0x0139:
                        ch = 0x91;
                        break;

                    case 0x013A:
                        ch = 0x92;
                        break;

                    case 0x013D:
                        ch = 0x95;
                        break;

                    case 0x013E:
                        ch = 0x96;
                        break;

                    case 0x0141:
                        ch = 0x9D;
                        break;

                    case 0x0142:
                        ch = 0x88;
                        break;

                    case 0x0143:
                        ch = 0xE3;
                        break;

                    case 0x0144:
                        ch = 0xE4;
                        break;

                    case 0x0147:
                        ch = 0xD5;
                        break;

                    case 0x0148:
                        ch = 0xE5;
                        break;

                    case 0x0150:
                        ch = 0x8A;
                        break;

                    case 0x0151:
                        ch = 0x8B;
                        break;

                    case 0x0154:
                        ch = 0xE8;
                        break;

                    case 0x0155:
                        ch = 0xEA;
                        break;

                    case 0x0158:
                        ch = 0xFC;
                        break;

                    case 0x0159:
                        ch = 0xFD;
                        break;

                    case 0x015A:
                        ch = 0x97;
                        break;

                    case 0x015B:
                        ch = 0x98;
                        break;

                    case 0x015E:
                        ch = 0xB8;
                        break;

                    case 0x015F:
                        ch = 0xAD;
                        break;

                    case 0x0160:
                        ch = 0xE6;
                        break;

                    case 0x0161:
                        ch = 0xE7;
                        break;

                    case 0x0162:
                        ch = 0xDD;
                        break;

                    case 0x0163:
                        ch = 0xEE;
                        break;

                    case 0x0164:
                        ch = 0x9B;
                        break;

                    case 0x0165:
                        ch = 0x9C;
                        break;

                    case 0x016E:
                        ch = 0xDE;
                        break;

                    case 0x016F:
                        ch = 0x85;
                        break;

                    case 0x0170:
                        ch = 0xEB;
                        break;

                    case 0x0171:
                        ch = 0xFB;
                        break;

                    case 0x0179:
                        ch = 0x8D;
                        break;

                    case 0x017A:
                        ch = 0xAB;
                        break;

                    case 0x017B:
                        ch = 0xBD;
                        break;

                    case 0x017C:
                        ch = 0xBE;
                        break;

                    case 0x017D:
                        ch = 0xA6;
                        break;

                    case 0x017E:
                        ch = 0xA7;
                        break;

                    case 0x02C7:
                        ch = 0xF3;
                        break;

                    case 0x02D8:
                        ch = 0xF4;
                        break;

                    case 0x02D9:
                        ch = 0xFA;
                        break;

                    case 0x02DB:
                        ch = 0xF2;
                        break;

                    case 0x02DD:
                        ch = 0xF1;
                        break;

                    case 0x2022:
                        ch = 0x07;
                        break;

                    case 0x203C:
                        ch = 0x13;
                        break;

                    case 0x2190:
                        ch = 0x1B;
                        break;

                    case 0x2191:
                        ch = 0x18;
                        break;

                    case 0x2192:
                        ch = 0x1A;
                        break;

                    case 0x2193:
                        ch = 0x19;
                        break;

                    case 0x2194:
                        ch = 0x1D;
                        break;

                    case 0x2195:
                        ch = 0x12;
                        break;

                    case 0x21A8:
                        ch = 0x17;
                        break;

                    case 0x221F:
                        ch = 0x1C;
                        break;

                    case 0x2302:
                        ch = 0x7F;
                        break;

                    case 0x2500:
                        ch = 0xC4;
                        break;

                    case 0x2502:
                        ch = 0xB3;
                        break;

                    case 0x250C:
                        ch = 0xDA;
                        break;

                    case 0x2510:
                        ch = 0xBF;
                        break;

                    case 0x2514:
                        ch = 0xC0;
                        break;

                    case 0x2518:
                        ch = 0xD9;
                        break;

                    case 0x251C:
                        ch = 0xC3;
                        break;

                    case 0x2524:
                        ch = 0xB4;
                        break;

                    case 0x252C:
                        ch = 0xC2;
                        break;

                    case 0x2534:
                        ch = 0xC1;
                        break;

                    case 0x253C:
                        ch = 0xC5;
                        break;

                    case 0x2550:
                        ch = 0xCD;
                        break;

                    case 0x2551:
                        ch = 0xBA;
                        break;

                    case 0x2554:
                        ch = 0xC9;
                        break;

                    case 0x2557:
                        ch = 0xBB;
                        break;

                    case 0x255A:
                        ch = 0xC8;
                        break;

                    case 0x255D:
                        ch = 0xBC;
                        break;

                    case 0x2560:
                        ch = 0xCC;
                        break;

                    case 0x2563:
                        ch = 0xB9;
                        break;

                    case 0x2566:
                        ch = 0xCB;
                        break;

                    case 0x2569:
                        ch = 0xCA;
                        break;

                    case 0x256C:
                        ch = 0xCE;
                        break;

                    case 0x2580:
                        ch = 0xDF;
                        break;

                    case 0x2584:
                        ch = 0xDC;
                        break;

                    case 0x2588:
                        ch = 0xDB;
                        break;

                    case 0x2591:
                        ch = 0xB0;
                        break;

                    case 0x2592:
                        ch = 0xB1;
                        break;

                    case 0x2593:
                        ch = 0xB2;
                        break;

                    case 0x25A0:
                        ch = 0xFE;
                        break;

                    case 0x25AC:
                        ch = 0x16;
                        break;

                    case 0x25B2:
                        ch = 0x1E;
                        break;

                    case 0x25BA:
                        ch = 0x10;
                        break;

                    case 0x25BC:
                        ch = 0x1F;
                        break;

                    case 0x25C4:
                        ch = 0x11;
                        break;

                    case 0x25CB:
                        ch = 0x09;
                        break;

                    case 0x25D8:
                        ch = 0x08;
                        break;

                    case 0x25D9:
                        ch = 0x0A;
                        break;

                    case 0x263A:
                        ch = 0x01;
                        break;

                    case 0x263B:
                        ch = 0x02;
                        break;

                    case 0x263C:
                        ch = 0x0F;
                        break;

                    case 0x2640:
                        ch = 0x0C;
                        break;

                    case 0x2642:
                        ch = 0x0B;
                        break;

                    case 0x2660:
                        ch = 0x06;
                        break;

                    case 0x2663:
                        ch = 0x05;
                        break;

                    case 0x2665:
                        ch = 0x03;
                        break;

                    case 0x2666:
                        ch = 0x04;
                        break;

                    case 0x266A:
                        ch = 0x0D;
                        break;

                    case 0x266C:
                        ch = 0x0E;
                        break;

                    case 0xFFE8:
                        ch = 0xB3;
                        break;

                    case 0xFFE9:
                        ch = 0x1B;
                        break;

                    case 0xFFEA:
                        ch = 0x18;
                        break;

                    case 0xFFEB:
                        ch = 0x1A;
                        break;

                    case 0xFFEC:
                        ch = 0x19;
                        break;

                    case 0xFFED:
                        ch = 0xFE;
                        break;

                    case 0xFFEE:
                        ch = 0x09;
                        break;

                    default:
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                        break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #7
0
		unsafe static int InternalGetBytes (char* chars, int count, byte* bytes, int bcount, EncoderFallback fallback, ref EncoderFallbackBuffer buffer, ref char leftOver, bool flush)
		{
			byte* end_bytes = bytes + bcount;
			byte* start_bytes = bytes;
			char* end = chars + count;
			char* start = chars;

			while (chars < end) {
				if (leftOver == 0) {
					for (; chars < end; chars++) {
						int ch = *chars;
						if (ch < '\x80') {
							if (bytes >= end_bytes)
								goto fail_no_space;
							*bytes++ = (byte) ch;
						} else if (ch < '\x800') {
							if (bytes + 1 >= end_bytes)
								goto fail_no_space;
							bytes[0] = (byte) (0xC0 | (ch >> 6));
							bytes[1] = (byte) (0x80 | (ch & 0x3F));
							bytes += 2;
						} else if (ch < '\uD800' || ch > '\uDFFF') {
							if (bytes + 2 >= end_bytes)
								goto fail_no_space;
							bytes[0] = (byte) (0xE0 | (ch >> 12));
							bytes[1] = (byte) (0x80 | ((ch >> 6) & 0x3F));
							bytes[2] = (byte) (0x80 | (ch & 0x3F));
							bytes += 3;
						} else if (ch <= '\uDBFF') {
							// This is a surrogate char, exit the inner loop.
							leftOver = *chars;
							chars++;
							break;
						} else {
							// We have a surrogate tail without 
							// leading surrogate.
							char[] fallback_chars = GetFallbackChars (chars, start, fallback, ref buffer); 
							char dummy = '\0';
							if (bytes + InternalGetByteCount (fallback_chars, 0, fallback_chars.Length, fallback, ref dummy, true) > end_bytes)
								goto fail_no_space;
							fixed (char *fb_chars = fallback_chars) {
								bytes += InternalGetBytes (fb_chars, fallback_chars.Length, bytes, bcount - (int) (bytes - start_bytes), fallback, ref buffer, ref dummy, true);
							}

							leftOver = '\0';
						}
					}
				} else {
					if (*chars >= '\uDC00' && *chars <= '\uDFFF') {
						// We have a correct surrogate pair.
						int ch = 0x10000 + (int) *chars - 0xDC00 + (((int) leftOver - 0xD800) << 10);
						if (bytes + 3 >= end_bytes)
							goto fail_no_space;
						bytes[0] = (byte) (0xF0 | (ch >> 18));
						bytes[1] = (byte) (0x80 | ((ch >> 12) & 0x3F));
						bytes[2] = (byte) (0x80 | ((ch >> 6) & 0x3F));
						bytes[3] = (byte) (0x80 | (ch & 0x3F));
						bytes += 4;
						chars++;
					} else {
						// We have a surrogate start followed by a
						// regular character.  Technically, this is
						// invalid, but we have to do something.
						// We write out the surrogate start and then
						// re-visit the current character again.
						char[] fallback_chars = GetFallbackChars (chars, start, fallback, ref buffer); 
						char dummy = '\0';

						if (bytes + InternalGetByteCount (fallback_chars, 0, fallback_chars.Length, fallback, ref dummy, true) > end_bytes)
							goto fail_no_space;

						fixed (char *fb_chars = fallback_chars) {
							InternalGetBytes (fb_chars, fallback_chars.Length, bytes, bcount - (int) (bytes - start_bytes), fallback, ref buffer, ref dummy, true);
						}

						leftOver = '\0';
					}

					leftOver = '\0';
				}
			}
			if (flush) {
				// Flush the left-over surrogate pair start.
				if (leftOver != '\0') {
					int ch = leftOver;
					if (bytes + 2 < end_bytes) {
						bytes[0] = (byte) (0xE0 | (ch >> 12));
						bytes[1] = (byte) (0x80 | ((ch >> 6) & 0x3F));
						bytes[2] = (byte) (0x80 | (ch & 0x3F));
						bytes += 3;
					} else {
						goto fail_no_space;
					}

					leftOver = '\0';
				}
			}

			return (int) (bytes - (end_bytes - bcount));

			fail_no_space:
			throw new ArgumentException ("Insufficient Space", "bytes");
		}
コード例 #8
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 161)
                {
                    switch (ch)
                    {
                    case 0x00A4:
                    case 0x00AD:
                        break;

                    case 0x060C:
                        ch = 0xAC;
                        break;

                    case 0x061B:
                        ch = 0xBB;
                        break;

                    case 0x061F:
                        ch = 0xBF;
                        break;

                    case 0x0621:
                    case 0x0622:
                    case 0x0623:
                    case 0x0624:
                    case 0x0625:
                    case 0x0626:
                    case 0x0627:
                    case 0x0628:
                    case 0x0629:
                    case 0x062A:
                    case 0x062B:
                    case 0x062C:
                    case 0x062D:
                    case 0x062E:
                    case 0x062F:
                    case 0x0630:
                    case 0x0631:
                    case 0x0632:
                    case 0x0633:
                    case 0x0634:
                    case 0x0635:
                    case 0x0636:
                    case 0x0637:
                    case 0x0638:
                    case 0x0639:
                    case 0x063A:
                        ch -= 0x0560;
                        break;

                    case 0x0640:
                    case 0x0641:
                    case 0x0642:
                    case 0x0643:
                    case 0x0644:
                    case 0x0645:
                    case 0x0646:
                    case 0x0647:
                    case 0x0648:
                    case 0x0649:
                    case 0x064A:
                    case 0x064B:
                    case 0x064C:
                    case 0x064D:
                    case 0x064E:
                    case 0x064F:
                    case 0x0650:
                    case 0x0651:
                    case 0x0652:
                        ch -= 0x0560;
                        break;

                    case 0x0660:
                    case 0x0661:
                    case 0x0662:
                    case 0x0663:
                    case 0x0664:
                    case 0x0665:
                    case 0x0666:
                    case 0x0667:
                    case 0x0668:
                    case 0x0669:
                        ch -= 0x0630;
                        break;

                    case 0x066A:
                        ch = 0x25;
                        break;

                    case 0x066B:
                        ch = 0x2C;
                        break;

                    case 0x066C:
                        ch = 0x2E;
                        break;

                    case 0x066D:
                        ch = 0x2A;
                        break;

                    case 0xFE70:
                        ch = 0xEB;
                        break;

                    case 0xFE71:
                        ch = 0xEB;
                        break;

                    case 0xFE72:
                        ch = 0xEC;
                        break;

                    case 0xFE74:
                        ch = 0xED;
                        break;

                    case 0xFE76:
                        ch = 0xEE;
                        break;

                    case 0xFE77:
                        ch = 0xEE;
                        break;

                    case 0xFE78:
                        ch = 0xEF;
                        break;

                    case 0xFE79:
                        ch = 0xEF;
                        break;

                    case 0xFE7A:
                        ch = 0xF0;
                        break;

                    case 0xFE7B:
                        ch = 0xF0;
                        break;

                    case 0xFE7C:
                        ch = 0xF1;
                        break;

                    case 0xFE7D:
                        ch = 0xF1;
                        break;

                    case 0xFE7E:
                        ch = 0xF2;
                        break;

                    case 0xFE7F:
                        ch = 0xF2;
                        break;

                    case 0xFE80:
                        ch = 0xC1;
                        break;

                    case 0xFE81:
                        ch = 0xC2;
                        break;

                    case 0xFE82:
                        ch = 0xC2;
                        break;

                    case 0xFE83:
                        ch = 0xC3;
                        break;

                    case 0xFE84:
                        ch = 0xC3;
                        break;

                    case 0xFE85:
                        ch = 0xC4;
                        break;

                    case 0xFE86:
                        ch = 0xC4;
                        break;

                    case 0xFE87:
                        ch = 0xC5;
                        break;

                    case 0xFE88:
                        ch = 0xC5;
                        break;

                    case 0xFE89:
                        ch = 0xC6;
                        break;

                    case 0xFE8A:
                        ch = 0xC6;
                        break;

                    case 0xFE8B:
                        ch = 0xC6;
                        break;

                    case 0xFE8C:
                        ch = 0xC6;
                        break;

                    case 0xFE8D:
                        ch = 0xC7;
                        break;

                    case 0xFE8E:
                        ch = 0xC7;
                        break;

                    case 0xFE8F:
                        ch = 0xC8;
                        break;

                    case 0xFE90:
                        ch = 0xC8;
                        break;

                    case 0xFE91:
                        ch = 0xC8;
                        break;

                    case 0xFE92:
                        ch = 0xC8;
                        break;

                    case 0xFE93:
                        ch = 0xC9;
                        break;

                    case 0xFE94:
                        ch = 0xC9;
                        break;

                    case 0xFE95:
                        ch = 0xCA;
                        break;

                    case 0xFE96:
                        ch = 0xCA;
                        break;

                    case 0xFE97:
                        ch = 0xCA;
                        break;

                    case 0xFE98:
                        ch = 0xCA;
                        break;

                    case 0xFE99:
                        ch = 0xCB;
                        break;

                    case 0xFE9A:
                        ch = 0xCB;
                        break;

                    case 0xFE9B:
                        ch = 0xCB;
                        break;

                    case 0xFE9C:
                        ch = 0xCB;
                        break;

                    case 0xFE9D:
                        ch = 0xCC;
                        break;

                    case 0xFE9E:
                        ch = 0xCC;
                        break;

                    case 0xFE9F:
                        ch = 0xCC;
                        break;

                    case 0xFEA0:
                        ch = 0xCC;
                        break;

                    case 0xFEA1:
                        ch = 0xCD;
                        break;

                    case 0xFEA2:
                        ch = 0xCD;
                        break;

                    case 0xFEA3:
                        ch = 0xCD;
                        break;

                    case 0xFEA4:
                        ch = 0xCD;
                        break;

                    case 0xFEA5:
                        ch = 0xCE;
                        break;

                    case 0xFEA6:
                        ch = 0xCE;
                        break;

                    case 0xFEA7:
                        ch = 0xCE;
                        break;

                    case 0xFEA8:
                        ch = 0xCE;
                        break;

                    case 0xFEA9:
                        ch = 0xCF;
                        break;

                    case 0xFEAA:
                        ch = 0xCF;
                        break;

                    case 0xFEAB:
                        ch = 0xD0;
                        break;

                    case 0xFEAC:
                        ch = 0xD0;
                        break;

                    case 0xFEAD:
                        ch = 0xD1;
                        break;

                    case 0xFEAE:
                        ch = 0xD1;
                        break;

                    case 0xFEAF:
                        ch = 0xD2;
                        break;

                    case 0xFEB0:
                        ch = 0xD2;
                        break;

                    case 0xFEB1:
                        ch = 0xD3;
                        break;

                    case 0xFEB2:
                        ch = 0xD3;
                        break;

                    case 0xFEB3:
                        ch = 0xD3;
                        break;

                    case 0xFEB4:
                        ch = 0xD3;
                        break;

                    case 0xFEB5:
                        ch = 0xD4;
                        break;

                    case 0xFEB6:
                        ch = 0xD4;
                        break;

                    case 0xFEB7:
                        ch = 0xD4;
                        break;

                    case 0xFEB8:
                        ch = 0xD4;
                        break;

                    case 0xFEB9:
                        ch = 0xD5;
                        break;

                    case 0xFEBA:
                        ch = 0xD5;
                        break;

                    case 0xFEBB:
                        ch = 0xD5;
                        break;

                    case 0xFEBC:
                        ch = 0xD5;
                        break;

                    case 0xFEBD:
                        ch = 0xD6;
                        break;

                    case 0xFEBE:
                        ch = 0xD6;
                        break;

                    case 0xFEBF:
                        ch = 0xD6;
                        break;

                    case 0xFEC0:
                        ch = 0xD6;
                        break;

                    case 0xFEC1:
                        ch = 0xD7;
                        break;

                    case 0xFEC2:
                        ch = 0xD7;
                        break;

                    case 0xFEC3:
                        ch = 0xD7;
                        break;

                    case 0xFEC4:
                        ch = 0xD7;
                        break;

                    case 0xFEC5:
                        ch = 0xD8;
                        break;

                    case 0xFEC6:
                        ch = 0xD8;
                        break;

                    case 0xFEC7:
                        ch = 0xD8;
                        break;

                    case 0xFEC8:
                        ch = 0xD8;
                        break;

                    case 0xFEC9:
                        ch = 0xD9;
                        break;

                    case 0xFECA:
                        ch = 0xD9;
                        break;

                    case 0xFECB:
                        ch = 0xD9;
                        break;

                    case 0xFECC:
                        ch = 0xD9;
                        break;

                    case 0xFECD:
                        ch = 0xDA;
                        break;

                    case 0xFECE:
                        ch = 0xDA;
                        break;

                    case 0xFECF:
                        ch = 0xDA;
                        break;

                    case 0xFED0:
                        ch = 0xDA;
                        break;

                    case 0xFED1:
                        ch = 0xE1;
                        break;

                    case 0xFED2:
                        ch = 0xE1;
                        break;

                    case 0xFED3:
                        ch = 0xE1;
                        break;

                    case 0xFED4:
                        ch = 0xE1;
                        break;

                    case 0xFED5:
                        ch = 0xE2;
                        break;

                    case 0xFED6:
                        ch = 0xE2;
                        break;

                    case 0xFED7:
                        ch = 0xE2;
                        break;

                    case 0xFED8:
                        ch = 0xE2;
                        break;

                    case 0xFED9:
                        ch = 0xE3;
                        break;

                    case 0xFEDA:
                        ch = 0xE3;
                        break;

                    case 0xFEDB:
                        ch = 0xE3;
                        break;

                    case 0xFEDC:
                        ch = 0xE3;
                        break;

                    case 0xFEDD:
                        ch = 0xE4;
                        break;

                    case 0xFEDE:
                        ch = 0xE4;
                        break;

                    case 0xFEDF:
                        ch = 0xE4;
                        break;

                    case 0xFEE0:
                        ch = 0xE4;
                        break;

                    case 0xFEE1:
                        ch = 0xE5;
                        break;

                    case 0xFEE2:
                        ch = 0xE5;
                        break;

                    case 0xFEE3:
                        ch = 0xE5;
                        break;

                    case 0xFEE4:
                        ch = 0xE5;
                        break;

                    case 0xFEE5:
                        ch = 0xE6;
                        break;

                    case 0xFEE6:
                        ch = 0xE6;
                        break;

                    case 0xFEE7:
                        ch = 0xE6;
                        break;

                    case 0xFEE8:
                        ch = 0xE6;
                        break;

                    case 0xFEE9:
                        ch = 0xE7;
                        break;

                    case 0xFEEA:
                        ch = 0xE7;
                        break;

                    case 0xFEEB:
                        ch = 0xE7;
                        break;

                    case 0xFEEC:
                        ch = 0xE7;
                        break;

                    case 0xFEED:
                        ch = 0xE8;
                        break;

                    case 0xFEEE:
                        ch = 0xE8;
                        break;

                    case 0xFEEF:
                        ch = 0xE9;
                        break;

                    case 0xFEF0:
                        ch = 0xE9;
                        break;

                    case 0xFEF1:
                        ch = 0xEA;
                        break;

                    case 0xFEF2:
                        ch = 0xEA;
                        break;

                    case 0xFEF3:
                        ch = 0xEA;
                        break;

                    case 0xFEF4:
                        ch = 0xEA;
                        break;

                    default:
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                        break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #9
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 4)
                {
                    switch (ch)
                    {
                    case 0x000B:
                    case 0x000C:
                    case 0x000D:
                    case 0x000E:
                    case 0x000F:
                    case 0x0010:
                    case 0x0011:
                    case 0x0012:
                    case 0x0013:
                    case 0x0018:
                    case 0x0019:
                    case 0x001C:
                    case 0x001D:
                    case 0x001E:
                    case 0x001F:
                        break;

                    case 0x0004:
                        ch = 0x37;
                        break;

                    case 0x0005:
                        ch = 0x2D;
                        break;

                    case 0x0006:
                        ch = 0x2E;
                        break;

                    case 0x0007:
                        ch = 0x2F;
                        break;

                    case 0x0008:
                        ch = 0x16;
                        break;

                    case 0x0009:
                        ch = 0x05;
                        break;

                    case 0x000A:
                        ch = 0x25;
                        break;

                    case 0x0014:
                        ch = 0x3C;
                        break;

                    case 0x0015:
                        ch = 0x3D;
                        break;

                    case 0x0016:
                        ch = 0x32;
                        break;

                    case 0x0017:
                        ch = 0x26;
                        break;

                    case 0x001A:
                        ch = 0x3F;
                        break;

                    case 0x001B:
                        ch = 0x27;
                        break;

                    case 0x0020:
                        ch = 0x40;
                        break;

                    case 0x0021:
                        ch = 0x5A;
                        break;

                    case 0x0022:
                        ch = 0x7F;
                        break;

                    case 0x0023:
                        ch = 0x7B;
                        break;

                    case 0x0024:
                        ch = 0xE0;
                        break;

                    case 0x0025:
                        ch = 0x6C;
                        break;

                    case 0x0026:
                        ch = 0x50;
                        break;

                    case 0x0027:
                        ch = 0x7D;
                        break;

                    case 0x0028:
                        ch = 0x4D;
                        break;

                    case 0x0029:
                        ch = 0x5D;
                        break;

                    case 0x002A:
                        ch = 0x5C;
                        break;

                    case 0x002B:
                        ch = 0x4E;
                        break;

                    case 0x002C:
                        ch = 0x6B;
                        break;

                    case 0x002D:
                        ch = 0x60;
                        break;

                    case 0x002E:
                        ch = 0x4B;
                        break;

                    case 0x002F:
                        ch = 0x61;
                        break;

                    case 0x0030:
                    case 0x0031:
                    case 0x0032:
                    case 0x0033:
                    case 0x0034:
                    case 0x0035:
                    case 0x0036:
                    case 0x0037:
                    case 0x0038:
                    case 0x0039:
                        ch += 0x00C0;
                        break;

                    case 0x003A:
                        ch = 0x7A;
                        break;

                    case 0x003B:
                        ch = 0x5E;
                        break;

                    case 0x003C:
                        ch = 0x4C;
                        break;

                    case 0x003D:
                        ch = 0x7E;
                        break;

                    case 0x003E:
                        ch = 0x6E;
                        break;

                    case 0x003F:
                        ch = 0x6F;
                        break;

                    case 0x0040:
                        ch = 0x7C;
                        break;

                    case 0x0041:
                    case 0x0042:
                    case 0x0043:
                    case 0x0044:
                    case 0x0045:
                    case 0x0046:
                    case 0x0047:
                    case 0x0048:
                    case 0x0049:
                        ch += 0x0080;
                        break;

                    case 0x004A:
                    case 0x004B:
                    case 0x004C:
                    case 0x004D:
                    case 0x004E:
                    case 0x004F:
                    case 0x0050:
                    case 0x0051:
                    case 0x0052:
                        ch += 0x0087;
                        break;

                    case 0x0053:
                    case 0x0054:
                    case 0x0055:
                    case 0x0056:
                    case 0x0057:
                    case 0x0058:
                    case 0x0059:
                    case 0x005A:
                        ch += 0x008F;
                        break;

                    case 0x005B:
                        ch = 0x70;
                        break;

                    case 0x005C:
                        ch = 0xB2;
                        break;

                    case 0x005D:
                        ch = 0x80;
                        break;

                    case 0x005E:
                        ch = 0xB0;
                        break;

                    case 0x005F:
                        ch = 0x6D;
                        break;

                    case 0x0060:
                        ch = 0x79;
                        break;

                    case 0x0061:
                    case 0x0062:
                    case 0x0063:
                    case 0x0064:
                    case 0x0065:
                    case 0x0066:
                    case 0x0067:
                    case 0x0068:
                        ch += 0x0001;
                        break;

                    case 0x0069:
                    case 0x006A:
                    case 0x006B:
                    case 0x006C:
                    case 0x006D:
                    case 0x006E:
                    case 0x006F:
                    case 0x0070:
                        ch += 0x0008;
                        break;

                    case 0x0071:
                        ch = 0x8B;
                        break;

                    case 0x0072:
                        ch = 0x9B;
                        break;

                    case 0x0073:
                        ch = 0xAB;
                        break;

                    case 0x0074:
                    case 0x0075:
                    case 0x0076:
                    case 0x0077:
                    case 0x0078:
                    case 0x0079:
                    case 0x007A:
                        ch += 0x003F;
                        break;

                    case 0x007B:
                        ch = 0xC0;
                        break;

                    case 0x007C:
                        ch = 0x4F;
                        break;

                    case 0x007D:
                        ch = 0xD0;
                        break;

                    case 0x007E:
                        ch = 0xA0;
                        break;

                    case 0x007F:
                        ch = 0x07;
                        break;

                    case 0x0080:
                    case 0x0081:
                    case 0x0082:
                    case 0x0083:
                    case 0x0084:
                        ch -= 0x0060;
                        break;

                    case 0x0085:
                        ch = 0x15;
                        break;

                    case 0x0086:
                        ch = 0x06;
                        break;

                    case 0x0087:
                        ch = 0x17;
                        break;

                    case 0x0088:
                    case 0x0089:
                    case 0x008A:
                    case 0x008B:
                    case 0x008C:
                        ch -= 0x0060;
                        break;

                    case 0x008D:
                        ch = 0x09;
                        break;

                    case 0x008E:
                        ch = 0x0A;
                        break;

                    case 0x008F:
                        ch = 0x1B;
                        break;

                    case 0x0090:
                        ch = 0x30;
                        break;

                    case 0x0091:
                        ch = 0x31;
                        break;

                    case 0x0092:
                        ch = 0x1A;
                        break;

                    case 0x0093:
                    case 0x0094:
                    case 0x0095:
                    case 0x0096:
                        ch -= 0x0060;
                        break;

                    case 0x0097:
                        ch = 0x08;
                        break;

                    case 0x0098:
                    case 0x0099:
                    case 0x009A:
                    case 0x009B:
                        ch -= 0x0060;
                        break;

                    case 0x009C:
                        ch = 0x04;
                        break;

                    case 0x009D:
                        ch = 0x14;
                        break;

                    case 0x009E:
                        ch = 0x3E;
                        break;

                    case 0x009F:
                        ch = 0xFF;
                        break;

                    case 0x00A2:
                        ch = 0xB1;
                        break;

                    case 0x00A3:
                        ch = 0x4A;
                        break;

                    case 0x00A5:
                        ch = 0x5B;
                        break;

                    case 0x00AC:
                        ch = 0x5F;
                        break;

                    case 0x203E:
                        ch = 0xA1;
                        break;

                    case 0xFF01:
                        ch = 0x5A;
                        break;

                    case 0xFF02:
                        ch = 0x7F;
                        break;

                    case 0xFF03:
                        ch = 0x7B;
                        break;

                    case 0xFF04:
                        ch = 0xE0;
                        break;

                    case 0xFF05:
                        ch = 0x6C;
                        break;

                    case 0xFF06:
                        ch = 0x50;
                        break;

                    case 0xFF07:
                        ch = 0x7D;
                        break;

                    case 0xFF08:
                        ch = 0x4D;
                        break;

                    case 0xFF09:
                        ch = 0x5D;
                        break;

                    case 0xFF0A:
                        ch = 0x5C;
                        break;

                    case 0xFF0B:
                        ch = 0x4E;
                        break;

                    case 0xFF0C:
                        ch = 0x6B;
                        break;

                    case 0xFF0D:
                        ch = 0x60;
                        break;

                    case 0xFF0E:
                        ch = 0x4B;
                        break;

                    case 0xFF0F:
                        ch = 0x61;
                        break;

                    case 0xFF10:
                    case 0xFF11:
                    case 0xFF12:
                    case 0xFF13:
                    case 0xFF14:
                    case 0xFF15:
                    case 0xFF16:
                    case 0xFF17:
                    case 0xFF18:
                    case 0xFF19:
                        ch -= 0xFE20;
                        break;

                    case 0xFF1A:
                        ch = 0x7A;
                        break;

                    case 0xFF1B:
                        ch = 0x5E;
                        break;

                    case 0xFF1C:
                        ch = 0x4C;
                        break;

                    case 0xFF1D:
                        ch = 0x7E;
                        break;

                    case 0xFF1E:
                        ch = 0x6E;
                        break;

                    case 0xFF1F:
                        ch = 0x6F;
                        break;

                    case 0xFF20:
                        ch = 0x7C;
                        break;

                    case 0xFF21:
                    case 0xFF22:
                    case 0xFF23:
                    case 0xFF24:
                    case 0xFF25:
                    case 0xFF26:
                    case 0xFF27:
                    case 0xFF28:
                    case 0xFF29:
                        ch -= 0xFE60;
                        break;

                    case 0xFF2A:
                    case 0xFF2B:
                    case 0xFF2C:
                    case 0xFF2D:
                    case 0xFF2E:
                    case 0xFF2F:
                    case 0xFF30:
                    case 0xFF31:
                    case 0xFF32:
                        ch -= 0xFE59;
                        break;

                    case 0xFF33:
                    case 0xFF34:
                    case 0xFF35:
                    case 0xFF36:
                    case 0xFF37:
                    case 0xFF38:
                    case 0xFF39:
                    case 0xFF3A:
                        ch -= 0xFE51;
                        break;

                    case 0xFF3B:
                        ch = 0x70;
                        break;

                    case 0xFF3C:
                        ch = 0xB2;
                        break;

                    case 0xFF3D:
                        ch = 0x80;
                        break;

                    case 0xFF3E:
                        ch = 0xB0;
                        break;

                    case 0xFF3F:
                        ch = 0x6D;
                        break;

                    case 0xFF40:
                        ch = 0x79;
                        break;

                    case 0xFF41:
                    case 0xFF42:
                    case 0xFF43:
                    case 0xFF44:
                    case 0xFF45:
                    case 0xFF46:
                    case 0xFF47:
                    case 0xFF48:
                        ch -= 0xFEDF;
                        break;

                    case 0xFF49:
                    case 0xFF4A:
                    case 0xFF4B:
                    case 0xFF4C:
                    case 0xFF4D:
                    case 0xFF4E:
                    case 0xFF4F:
                    case 0xFF50:
                        ch -= 0xFED8;
                        break;

                    case 0xFF51:
                        ch = 0x8B;
                        break;

                    case 0xFF52:
                        ch = 0x9B;
                        break;

                    case 0xFF53:
                        ch = 0xAB;
                        break;

                    case 0xFF54:
                    case 0xFF55:
                    case 0xFF56:
                    case 0xFF57:
                    case 0xFF58:
                    case 0xFF59:
                    case 0xFF5A:
                        ch -= 0xFEA1;
                        break;

                    case 0xFF5B:
                        ch = 0xC0;
                        break;

                    case 0xFF5C:
                        ch = 0x4F;
                        break;

                    case 0xFF5D:
                        ch = 0xD0;
                        break;

                    case 0xFF5E:
                        ch = 0xA0;
                        break;

                    case 0xFF61:
                    case 0xFF62:
                    case 0xFF63:
                    case 0xFF64:
                    case 0xFF65:
                    case 0xFF66:
                    case 0xFF67:
                    case 0xFF68:
                    case 0xFF69:
                        ch -= 0xFF20;
                        break;

                    case 0xFF6A:
                    case 0xFF6B:
                    case 0xFF6C:
                    case 0xFF6D:
                    case 0xFF6E:
                    case 0xFF6F:
                        ch -= 0xFF19;
                        break;

                    case 0xFF70:
                        ch = 0x58;
                        break;

                    case 0xFF71:
                    case 0xFF72:
                    case 0xFF73:
                    case 0xFF74:
                    case 0xFF75:
                    case 0xFF76:
                    case 0xFF77:
                    case 0xFF78:
                    case 0xFF79:
                    case 0xFF7A:
                        ch -= 0xFEF0;
                        break;

                    case 0xFF7B:
                    case 0xFF7C:
                    case 0xFF7D:
                    case 0xFF7E:
                    case 0xFF7F:
                    case 0xFF80:
                    case 0xFF81:
                    case 0xFF82:
                    case 0xFF83:
                    case 0xFF84:
                    case 0xFF85:
                    case 0xFF86:
                    case 0xFF87:
                    case 0xFF88:
                    case 0xFF89:
                        ch -= 0xFEEF;
                        break;

                    case 0xFF8A:
                        ch = 0x9D;
                        break;

                    case 0xFF8B:
                        ch = 0x9E;
                        break;

                    case 0xFF8C:
                        ch = 0x9F;
                        break;

                    case 0xFF8D:
                    case 0xFF8E:
                    case 0xFF8F:
                    case 0xFF90:
                    case 0xFF91:
                    case 0xFF92:
                    case 0xFF93:
                    case 0xFF94:
                    case 0xFF95:
                        ch -= 0xFEEB;
                        break;

                    case 0xFF96:
                    case 0xFF97:
                    case 0xFF98:
                    case 0xFF99:
                        ch -= 0xFEEA;
                        break;

                    case 0xFF9A:
                    case 0xFF9B:
                    case 0xFF9C:
                    case 0xFF9D:
                    case 0xFF9E:
                    case 0xFF9F:
                        ch -= 0xFEE0;
                        break;

                    default:
                        HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                        continue;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #10
0
		unsafe static char[] GetFallbackChars (char* chars, char* start, EncoderFallback fallback, ref EncoderFallbackBuffer buffer)
		{
			if (buffer == null)
				buffer = fallback.CreateFallbackBuffer ();

			buffer.Fallback (*chars, (int) (chars - start));

			char[] fallback_chars = new char [buffer.Remaining];
			for (int i = 0; i < fallback_chars.Length; i++)
				fallback_chars [i] = buffer.GetNextChar ();

			buffer.Reset ();

			return fallback_chars;
		}
コード例 #11
0
        unsafe static char[] GetFallbackChars(char *chars, char *start, EncoderFallback fallback, ref EncoderFallbackBuffer buffer)
        {
            if (buffer == null)
            {
                buffer = fallback.CreateFallbackBuffer();
            }

            buffer.Fallback(*chars, (int)(chars - start));

            char[] fallback_chars = new char [buffer.Remaining];
            for (int i = 0; i < fallback_chars.Length; i++)
            {
                fallback_chars [i] = buffer.GetNextChar();
            }

            buffer.Reset();

            return(fallback_chars);
        }
コード例 #12
0
        // Internal version of "GetBytes" which can handle a rolling
        // state between multiple calls to this method.
        static int InternalGetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, EncoderFallback fallback, ref EncoderFallbackBuffer buffer, ref char leftOver, bool flush)
        {
            // Validate the parameters.
            if (chars == null)
            {
                throw new ArgumentNullException("chars");
            }

            if (bytes == null)
            {
                throw new ArgumentNullException("bytes");
            }

            if (charIndex < 0 || charIndex > chars.Length)
            {
                throw new ArgumentOutOfRangeException("charIndex");
            }

            if (charCount < 0 || charCount > (chars.Length - charIndex))
            {
                throw new ArgumentOutOfRangeException("charCount");
            }

            if (byteIndex < 0 || byteIndex > bytes.Length)
            {
                throw new ArgumentOutOfRangeException("byteIndex");
            }

            if (charIndex == chars.Length)
            {
                if (flush && leftOver != '\0')
                {
                    // FIXME: use EncoderFallback.
                    //
                    // By default it is empty, so I do nothing for now.
                    leftOver = '\0';
                }

                return(0);
            }

            unsafe
            {
                fixed(char *cptr = chars)
                {
                    if (bytes.Length == byteIndex)
                    {
                        return(InternalGetBytes(cptr + charIndex, charCount, null, 0, fallback, ref buffer, ref leftOver, flush));

                        fixed(byte *bptr = bytes)
                        {
                            return(InternalGetBytes(cptr + charIndex, charCount, bptr + byteIndex, bytes.Length - byteIndex, fallback, ref buffer, ref leftOver, flush));
                        }
                }
            }
        }

        unsafe static int InternalGetBytes(char *chars, int count, byte *bytes, int bcount, EncoderFallback fallback, ref EncoderFallbackBuffer buffer, ref char leftOver, bool flush)
コード例 #13
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 161)
                {
                    switch (ch)
                    {
                    case 0x00A4:
                    case 0x00A7:
                    case 0x00A8:
                    case 0x00AD:
                    case 0x00B0:
                    case 0x00B4:
                    case 0x00B8:
                    case 0x00C1:
                    case 0x00C2:
                    case 0x00C4:
                    case 0x00C7:
                    case 0x00C9:
                    case 0x00CB:
                    case 0x00CD:
                    case 0x00CE:
                    case 0x00D0:
                    case 0x00D3:
                    case 0x00D4:
                    case 0x00D6:
                    case 0x00D7:
                    case 0x00DA:
                    case 0x00DC:
                    case 0x00DD:
                    case 0x00DF:
                    case 0x00E1:
                    case 0x00E2:
                    case 0x00E4:
                    case 0x00E7:
                    case 0x00E9:
                    case 0x00EB:
                    case 0x00ED:
                    case 0x00EE:
                    case 0x00F3:
                    case 0x00F4:
                    case 0x00F6:
                    case 0x00F7:
                    case 0x00FA:
                    case 0x00FC:
                    case 0x00FD:
                        break;

                    case 0x00A2:
                        ch = 0x8D;
                        break;

                    case 0x00A5:
                        ch = 0x8E;
                        break;

                    case 0x00A9:
                        ch = 0x88;
                        break;

                    case 0x00AE:
                        ch = 0x9F;
                        break;

                    case 0x00B6:
                        ch = 0x14;
                        break;

                    case 0x0102:
                        ch = 0xC3;
                        break;

                    case 0x0103:
                        ch = 0xE3;
                        break;

                    case 0x0104:
                        ch = 0xA1;
                        break;

                    case 0x0105:
                        ch = 0xB1;
                        break;

                    case 0x0106:
                        ch = 0xC6;
                        break;

                    case 0x0107:
                        ch = 0xE6;
                        break;

                    case 0x010C:
                        ch = 0xC8;
                        break;

                    case 0x010D:
                        ch = 0xE8;
                        break;

                    case 0x010E:
                        ch = 0xCF;
                        break;

                    case 0x010F:
                        ch = 0xEF;
                        break;

                    case 0x0110:
                        ch = 0xD0;
                        break;

                    case 0x0111:
                        ch = 0xF0;
                        break;

                    case 0x0118:
                        ch = 0xCA;
                        break;

                    case 0x0119:
                        ch = 0xEA;
                        break;

                    case 0x011A:
                        ch = 0xCC;
                        break;

                    case 0x011B:
                        ch = 0xEC;
                        break;

                    case 0x0139:
                        ch = 0xC5;
                        break;

                    case 0x013A:
                        ch = 0xE5;
                        break;

                    case 0x013D:
                        ch = 0xA5;
                        break;

                    case 0x013E:
                        ch = 0xB5;
                        break;

                    case 0x0141:
                        ch = 0xA3;
                        break;

                    case 0x0142:
                        ch = 0xB3;
                        break;

                    case 0x0143:
                        ch = 0xD1;
                        break;

                    case 0x0144:
                        ch = 0xF1;
                        break;

                    case 0x0147:
                        ch = 0xD2;
                        break;

                    case 0x0148:
                        ch = 0xF2;
                        break;

                    case 0x0150:
                        ch = 0xD5;
                        break;

                    case 0x0151:
                        ch = 0xF5;
                        break;

                    case 0x0154:
                        ch = 0xC0;
                        break;

                    case 0x0155:
                        ch = 0xE0;
                        break;

                    case 0x0158:
                        ch = 0xD8;
                        break;

                    case 0x0159:
                        ch = 0xF8;
                        break;

                    case 0x015A:
                        ch = 0xA6;
                        break;

                    case 0x015B:
                        ch = 0xB6;
                        break;

                    case 0x015E:
                        ch = 0xAA;
                        break;

                    case 0x015F:
                        ch = 0xBA;
                        break;

                    case 0x0160:
                        ch = 0xA9;
                        break;

                    case 0x0161:
                        ch = 0xB9;
                        break;

                    case 0x0162:
                        ch = 0xDE;
                        break;

                    case 0x0163:
                        ch = 0xFE;
                        break;

                    case 0x0164:
                        ch = 0xAB;
                        break;

                    case 0x0165:
                        ch = 0xBB;
                        break;

                    case 0x016E:
                        ch = 0xD9;
                        break;

                    case 0x016F:
                        ch = 0xF9;
                        break;

                    case 0x0170:
                        ch = 0xDB;
                        break;

                    case 0x0171:
                        ch = 0xFB;
                        break;

                    case 0x0179:
                        ch = 0xAC;
                        break;

                    case 0x017A:
                        ch = 0xBC;
                        break;

                    case 0x017B:
                        ch = 0xAF;
                        break;

                    case 0x017C:
                        ch = 0xBF;
                        break;

                    case 0x017D:
                        ch = 0xAE;
                        break;

                    case 0x017E:
                        ch = 0xBE;
                        break;

                    case 0x02C7:
                        ch = 0xB7;
                        break;

                    case 0x02D8:
                        ch = 0xA2;
                        break;

                    case 0x02D9:
                        ch = 0xFF;
                        break;

                    case 0x02DB:
                        ch = 0xB2;
                        break;

                    case 0x02DD:
                        ch = 0xBD;
                        break;

                    case 0x2022:
                        ch = 0x07;
                        break;

                    case 0x203C:
                        ch = 0x13;
                        break;

                    case 0x2190:
                        ch = 0x1B;
                        break;

                    case 0x2191:
                        ch = 0x18;
                        break;

                    case 0x2192:
                        ch = 0x1A;
                        break;

                    case 0x2193:
                        ch = 0x19;
                        break;

                    case 0x2194:
                        ch = 0x1D;
                        break;

                    case 0x2195:
                        ch = 0x12;
                        break;

                    case 0x21A8:
                        ch = 0x17;
                        break;

                    case 0x221F:
                        ch = 0x1C;
                        break;

                    case 0x2500:
                        ch = 0x94;
                        break;

                    case 0x2502:
                        ch = 0x83;
                        break;

                    case 0x250C:
                        ch = 0x86;
                        break;

                    case 0x2510:
                        ch = 0x8F;
                        break;

                    case 0x2514:
                        ch = 0x90;
                        break;

                    case 0x2518:
                        ch = 0x85;
                        break;

                    case 0x251C:
                        ch = 0x93;
                        break;

                    case 0x2524:
                        ch = 0x84;
                        break;

                    case 0x252C:
                        ch = 0x92;
                        break;

                    case 0x2534:
                        ch = 0x91;
                        break;

                    case 0x253C:
                        ch = 0x95;
                        break;

                    case 0x2550:
                        ch = 0x9D;
                        break;

                    case 0x2551:
                        ch = 0x8A;
                        break;

                    case 0x2554:
                        ch = 0x99;
                        break;

                    case 0x2557:
                        ch = 0x8B;
                        break;

                    case 0x255A:
                        ch = 0x98;
                        break;

                    case 0x255D:
                        ch = 0x8C;
                        break;

                    case 0x2560:
                        ch = 0x9C;
                        break;

                    case 0x2563:
                        ch = 0x89;
                        break;

                    case 0x2566:
                        ch = 0x9B;
                        break;

                    case 0x2569:
                        ch = 0x9A;
                        break;

                    case 0x256C:
                        ch = 0x9E;
                        break;

                    case 0x2580:
                        ch = 0x97;
                        break;

                    case 0x2584:
                        ch = 0x96;
                        break;

                    case 0x2588:
                        ch = 0x87;
                        break;

                    case 0x2591:
                        ch = 0x80;
                        break;

                    case 0x2592:
                        ch = 0x81;
                        break;

                    case 0x2593:
                        ch = 0x82;
                        break;

                    case 0x25AC:
                        ch = 0x16;
                        break;

                    case 0x25B2:
                        ch = 0x1E;
                        break;

                    case 0x25BA:
                        ch = 0x10;
                        break;

                    case 0x25BC:
                        ch = 0x1F;
                        break;

                    case 0x25C4:
                        ch = 0x11;
                        break;

                    case 0x25CB:
                        ch = 0x09;
                        break;

                    case 0x25D8:
                        ch = 0x08;
                        break;

                    case 0x25D9:
                        ch = 0x0A;
                        break;

                    case 0x263A:
                        ch = 0x01;
                        break;

                    case 0x263B:
                        ch = 0x02;
                        break;

                    case 0x263C:
                        ch = 0x0F;
                        break;

                    case 0x2640:
                        ch = 0x0C;
                        break;

                    case 0x2642:
                        ch = 0x0B;
                        break;

                    case 0x2660:
                        ch = 0x06;
                        break;

                    case 0x2663:
                        ch = 0x05;
                        break;

                    case 0x2665:
                        ch = 0x03;
                        break;

                    case 0x2666:
                        ch = 0x04;
                        break;

                    case 0x266A:
                        ch = 0x0D;
                        break;

                    case 0x266C:
                        ch = 0x0E;
                        break;

                    case 0xFFE8:
                        ch = 0x83;
                        break;

                    case 0xFFE9:
                        ch = 0x1B;
                        break;

                    case 0xFFEA:
                        ch = 0x18;
                        break;

                    case 0xFFEB:
                        ch = 0x1A;
                        break;

                    case 0xFFEC:
                        ch = 0x19;
                        break;

                    case 0xFFEE:
                        ch = 0x09;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #14
0
        unsafe static int InternalGetByteCount(char *chars, int count, EncoderFallback fallback, ref char leftOver, bool flush)
        {
            EncoderFallbackBuffer buffer = null;
            char *end    = chars + count;
            char *start  = chars;
            int   length = 0;

            while (chars < end)
            {
                if (leftOver == 0)
                {
                    for (; chars < end; chars++)
                    {
                        if (*chars < '\x80')
                        {
                            ++length;
                        }
                        else if (*chars < '\x800')
                        {
                            length += 2;
                        }
                        else if (*chars < '\uD800' || *chars > '\uDFFF')
                        {
                            length += 3;
                        }
                        else if (*chars <= '\uDBFF')
                        {
                            // This is a surrogate start char, exit the inner loop only
                            // if we don't find the complete surrogate pair.
                            if (chars + 1 < end && chars [1] >= '\uDC00' && chars [1] <= '\uDFFF')
                            {
                                length += 4;
                                chars++;
                                continue;
                            }
                            leftOver = *chars;
                            chars++;
                            break;
                        }
                        else
                        {
                            // We have a surrogate tail without
                            // leading surrogate.
                            char[] fallback_chars = GetFallbackChars(chars, start, fallback, ref buffer);
                            fixed(char *fb_chars = fallback_chars)
                            {
                                char dummy = '\0';

                                length += InternalGetByteCount(fb_chars, fallback_chars.Length, fallback, ref dummy, true);
                            }

                            leftOver = '\0';
                        }
                    }
                }
                else
                {
                    if (*chars >= '\uDC00' && *chars <= '\uDFFF')
                    {
                        // We have a correct surrogate pair.
                        length += 4;
                        chars++;
                    }
                    else
                    {
                        // We have a surrogate start followed by a
                        // regular character.  Technically, this is
                        // invalid, but we have to do something.
                        // We write out the surrogate start and then
                        // re-visit the current character again.
                        char[] fallback_chars = GetFallbackChars(chars, start, fallback, ref buffer);
                        fixed(char *fb_chars = fallback_chars)
                        {
                            char dummy = '\0';

                            length += InternalGetByteCount(fb_chars, fallback_chars.Length, fallback, ref dummy, true);
                        }
                    }
                    leftOver = '\0';
                }
            }
            if (flush)
            {
                // Flush the left-over surrogate pair start.
                if (leftOver != '\0')
                {
                    length  += 3;
                    leftOver = '\0';
                }
            }
            return(length);
        }
コード例 #15
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 26)
                {
                    switch (ch)
                    {
                    case 0x001B:
                    case 0x001D:
                    case 0x001E:
                    case 0x001F:
                    case 0x0020:
                    case 0x0021:
                    case 0x0022:
                    case 0x0023:
                    case 0x0024:
                    case 0x0025:
                    case 0x0026:
                    case 0x0027:
                    case 0x0028:
                    case 0x0029:
                    case 0x002A:
                    case 0x002B:
                    case 0x002C:
                    case 0x002D:
                    case 0x002E:
                    case 0x002F:
                    case 0x0030:
                    case 0x0031:
                    case 0x0032:
                    case 0x0033:
                    case 0x0034:
                    case 0x0035:
                    case 0x0036:
                    case 0x0037:
                    case 0x0038:
                    case 0x0039:
                    case 0x003A:
                    case 0x003B:
                    case 0x003C:
                    case 0x003D:
                    case 0x003E:
                    case 0x003F:
                    case 0x0040:
                    case 0x0041:
                    case 0x0042:
                    case 0x0043:
                    case 0x0044:
                    case 0x0045:
                    case 0x0046:
                    case 0x0047:
                    case 0x0048:
                    case 0x0049:
                    case 0x004A:
                    case 0x004B:
                    case 0x004C:
                    case 0x004D:
                    case 0x004E:
                    case 0x004F:
                    case 0x0050:
                    case 0x0051:
                    case 0x0052:
                    case 0x0053:
                    case 0x0054:
                    case 0x0055:
                    case 0x0056:
                    case 0x0057:
                    case 0x0058:
                    case 0x0059:
                    case 0x005A:
                    case 0x005B:
                    case 0x005C:
                    case 0x005D:
                    case 0x005E:
                    case 0x005F:
                    case 0x0060:
                    case 0x0061:
                    case 0x0062:
                    case 0x0063:
                    case 0x0064:
                    case 0x0065:
                    case 0x0066:
                    case 0x0067:
                    case 0x0068:
                    case 0x0069:
                    case 0x006A:
                    case 0x006B:
                    case 0x006C:
                    case 0x006D:
                    case 0x006E:
                    case 0x006F:
                    case 0x0070:
                    case 0x0071:
                    case 0x0072:
                    case 0x0073:
                    case 0x0074:
                    case 0x0075:
                    case 0x0076:
                    case 0x0077:
                    case 0x0078:
                    case 0x0079:
                    case 0x007A:
                    case 0x007B:
                    case 0x007C:
                    case 0x007D:
                    case 0x007E:
                        break;

                    case 0x001A:
                        ch = 0x7F;
                        break;

                    case 0x001C:
                        ch = 0x1A;
                        break;

                    case 0x007F:
                        ch = 0x1C;
                        break;

                    case 0x00A0:
                        ch = 0xFF;
                        break;

                    case 0x00A1:
                        ch = 0xAD;
                        break;

                    case 0x00A2:
                        ch = 0x9B;
                        break;

                    case 0x00A3:
                        ch = 0x9C;
                        break;

                    case 0x00A5:
                        ch = 0x9D;
                        break;

                    case 0x00A7:
                        ch = 0x15;
                        break;

                    case 0x00AA:
                        ch = 0xA6;
                        break;

                    case 0x00AB:
                        ch = 0xAE;
                        break;

                    case 0x00AC:
                        ch = 0xAA;
                        break;

                    case 0x00B0:
                        ch = 0xF8;
                        break;

                    case 0x00B1:
                        ch = 0xF1;
                        break;

                    case 0x00B2:
                        ch = 0xFD;
                        break;

                    case 0x00B6:
                        ch = 0x14;
                        break;

                    case 0x00B7:
                        ch = 0xFA;
                        break;

                    case 0x00BA:
                        ch = 0xA7;
                        break;

                    case 0x00BB:
                        ch = 0xAF;
                        break;

                    case 0x00BC:
                        ch = 0xAC;
                        break;

                    case 0x00BD:
                        ch = 0xAB;
                        break;

                    case 0x00BF:
                        ch = 0xA8;
                        break;

                    case 0x00D1:
                        ch = 0xA5;
                        break;

                    case 0x00DF:
                        ch = 0xE1;
                        break;

                    case 0x00E1:
                        ch = 0xA0;
                        break;

                    case 0x00ED:
                        ch = 0xA1;
                        break;

                    case 0x00F1:
                        ch = 0xA4;
                        break;

                    case 0x00F3:
                        ch = 0xA2;
                        break;

                    case 0x00F7:
                        ch = 0xF6;
                        break;

                    case 0x00FA:
                        ch = 0xA3;
                        break;

                    case 0x0192:
                        ch = 0x9F;
                        break;

                    case 0x0393:
                        ch = 0xE2;
                        break;

                    case 0x0398:
                        ch = 0xE9;
                        break;

                    case 0x03A3:
                        ch = 0xE4;
                        break;

                    case 0x03A6:
                        ch = 0xE8;
                        break;

                    case 0x03A9:
                        ch = 0xEA;
                        break;

                    case 0x03B1:
                        ch = 0xE0;
                        break;

                    case 0x03B4:
                        ch = 0xEB;
                        break;

                    case 0x03B5:
                        ch = 0xEE;
                        break;

                    case 0x03BC:
                        ch = 0xE6;
                        break;

                    case 0x03C0:
                        ch = 0xE3;
                        break;

                    case 0x03C3:
                        ch = 0xE5;
                        break;

                    case 0x03C4:
                        ch = 0xE7;
                        break;

                    case 0x03C6:
                        ch = 0xED;
                        break;

                    case 0x05D0:
                    case 0x05D1:
                    case 0x05D2:
                    case 0x05D3:
                    case 0x05D4:
                    case 0x05D5:
                    case 0x05D6:
                    case 0x05D7:
                    case 0x05D8:
                    case 0x05D9:
                    case 0x05DA:
                    case 0x05DB:
                    case 0x05DC:
                    case 0x05DD:
                    case 0x05DE:
                    case 0x05DF:
                    case 0x05E0:
                    case 0x05E1:
                    case 0x05E2:
                    case 0x05E3:
                    case 0x05E4:
                    case 0x05E5:
                    case 0x05E6:
                    case 0x05E7:
                    case 0x05E8:
                    case 0x05E9:
                    case 0x05EA:
                        ch -= 0x0550;
                        break;

                    case 0x2022:
                        ch = 0x07;
                        break;

                    case 0x203C:
                        ch = 0x13;
                        break;

                    case 0x207F:
                        ch = 0xFC;
                        break;

                    case 0x20A7:
                        ch = 0x9E;
                        break;

                    case 0x2190:
                        ch = 0x1B;
                        break;

                    case 0x2191:
                        ch = 0x18;
                        break;

                    case 0x2192:
                        ch = 0x1A;
                        break;

                    case 0x2193:
                        ch = 0x19;
                        break;

                    case 0x2194:
                        ch = 0x1D;
                        break;

                    case 0x2195:
                        ch = 0x12;
                        break;

                    case 0x21A8:
                        ch = 0x17;
                        break;

                    case 0x2219:
                        ch = 0xF9;
                        break;

                    case 0x221A:
                        ch = 0xFB;
                        break;

                    case 0x221E:
                        ch = 0xEC;
                        break;

                    case 0x221F:
                        ch = 0x1C;
                        break;

                    case 0x2229:
                        ch = 0xEF;
                        break;

                    case 0x2248:
                        ch = 0xF7;
                        break;

                    case 0x2261:
                        ch = 0xF0;
                        break;

                    case 0x2264:
                        ch = 0xF3;
                        break;

                    case 0x2265:
                        ch = 0xF2;
                        break;

                    case 0x2302:
                        ch = 0x7F;
                        break;

                    case 0x2310:
                        ch = 0xA9;
                        break;

                    case 0x2320:
                        ch = 0xF4;
                        break;

                    case 0x2321:
                        ch = 0xF5;
                        break;

                    case 0x2500:
                        ch = 0xC4;
                        break;

                    case 0x2502:
                        ch = 0xB3;
                        break;

                    case 0x250C:
                        ch = 0xDA;
                        break;

                    case 0x2510:
                        ch = 0xBF;
                        break;

                    case 0x2514:
                        ch = 0xC0;
                        break;

                    case 0x2518:
                        ch = 0xD9;
                        break;

                    case 0x251C:
                        ch = 0xC3;
                        break;

                    case 0x2524:
                        ch = 0xB4;
                        break;

                    case 0x252C:
                        ch = 0xC2;
                        break;

                    case 0x2534:
                        ch = 0xC1;
                        break;

                    case 0x253C:
                        ch = 0xC5;
                        break;

                    case 0x2550:
                        ch = 0xCD;
                        break;

                    case 0x2551:
                        ch = 0xBA;
                        break;

                    case 0x2552:
                        ch = 0xD5;
                        break;

                    case 0x2553:
                        ch = 0xD6;
                        break;

                    case 0x2554:
                        ch = 0xC9;
                        break;

                    case 0x2555:
                        ch = 0xB8;
                        break;

                    case 0x2556:
                        ch = 0xB7;
                        break;

                    case 0x2557:
                        ch = 0xBB;
                        break;

                    case 0x2558:
                        ch = 0xD4;
                        break;

                    case 0x2559:
                        ch = 0xD3;
                        break;

                    case 0x255A:
                        ch = 0xC8;
                        break;

                    case 0x255B:
                        ch = 0xBE;
                        break;

                    case 0x255C:
                        ch = 0xBD;
                        break;

                    case 0x255D:
                        ch = 0xBC;
                        break;

                    case 0x255E:
                        ch = 0xC6;
                        break;

                    case 0x255F:
                        ch = 0xC7;
                        break;

                    case 0x2560:
                        ch = 0xCC;
                        break;

                    case 0x2561:
                        ch = 0xB5;
                        break;

                    case 0x2562:
                        ch = 0xB6;
                        break;

                    case 0x2563:
                        ch = 0xB9;
                        break;

                    case 0x2564:
                        ch = 0xD1;
                        break;

                    case 0x2565:
                        ch = 0xD2;
                        break;

                    case 0x2566:
                        ch = 0xCB;
                        break;

                    case 0x2567:
                        ch = 0xCF;
                        break;

                    case 0x2568:
                        ch = 0xD0;
                        break;

                    case 0x2569:
                        ch = 0xCA;
                        break;

                    case 0x256A:
                        ch = 0xD8;
                        break;

                    case 0x256B:
                        ch = 0xD7;
                        break;

                    case 0x256C:
                        ch = 0xCE;
                        break;

                    case 0x2580:
                        ch = 0xDF;
                        break;

                    case 0x2584:
                        ch = 0xDC;
                        break;

                    case 0x2588:
                        ch = 0xDB;
                        break;

                    case 0x258C:
                        ch = 0xDD;
                        break;

                    case 0x2590:
                        ch = 0xDE;
                        break;

                    case 0x2591:
                        ch = 0xB0;
                        break;

                    case 0x2592:
                        ch = 0xB1;
                        break;

                    case 0x2593:
                        ch = 0xB2;
                        break;

                    case 0x25A0:
                        ch = 0xFE;
                        break;

                    case 0x25AC:
                        ch = 0x16;
                        break;

                    case 0x25B2:
                        ch = 0x1E;
                        break;

                    case 0x25BA:
                        ch = 0x10;
                        break;

                    case 0x25BC:
                        ch = 0x1F;
                        break;

                    case 0x25C4:
                        ch = 0x11;
                        break;

                    case 0x25CB:
                        ch = 0x09;
                        break;

                    case 0x25D8:
                        ch = 0x08;
                        break;

                    case 0x25D9:
                        ch = 0x0A;
                        break;

                    case 0x263A:
                        ch = 0x01;
                        break;

                    case 0x263B:
                        ch = 0x02;
                        break;

                    case 0x263C:
                        ch = 0x0F;
                        break;

                    case 0x2640:
                        ch = 0x0C;
                        break;

                    case 0x2642:
                        ch = 0x0B;
                        break;

                    case 0x2660:
                        ch = 0x06;
                        break;

                    case 0x2663:
                        ch = 0x05;
                        break;

                    case 0x2665:
                        ch = 0x03;
                        break;

                    case 0x2666:
                        ch = 0x04;
                        break;

                    case 0x266A:
                        ch = 0x0D;
                        break;

                    case 0x266B:
                        ch = 0x0E;
                        break;

                    case 0xFFE8:
                        ch = 0xB3;
                        break;

                    case 0xFFE9:
                        ch = 0x1B;
                        break;

                    case 0xFFEA:
                        ch = 0x18;
                        break;

                    case 0xFFEB:
                        ch = 0x1A;
                        break;

                    case 0xFFEC:
                        ch = 0x19;
                        break;

                    case 0xFFED:
                        ch = 0xFE;
                        break;

                    case 0xFFEE:
                        ch = 0x09;
                        break;

                    default:
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                        break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #16
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 4)
                {
                    switch (ch)
                    {
                    case 0x000B:
                    case 0x000C:
                    case 0x000D:
                    case 0x000E:
                    case 0x000F:
                    case 0x0010:
                    case 0x0011:
                    case 0x0012:
                    case 0x0013:
                    case 0x0018:
                    case 0x0019:
                    case 0x001C:
                    case 0x001D:
                    case 0x001E:
                    case 0x001F:
                        break;

                    case 0x0004:
                        ch = 0x37;
                        break;

                    case 0x0005:
                        ch = 0x2D;
                        break;

                    case 0x0006:
                        ch = 0x2E;
                        break;

                    case 0x0007:
                        ch = 0x2F;
                        break;

                    case 0x0008:
                        ch = 0x16;
                        break;

                    case 0x0009:
                        ch = 0x05;
                        break;

                    case 0x000A:
                        ch = 0x25;
                        break;

                    case 0x0014:
                        ch = 0x3C;
                        break;

                    case 0x0015:
                        ch = 0x3D;
                        break;

                    case 0x0016:
                        ch = 0x32;
                        break;

                    case 0x0017:
                        ch = 0x26;
                        break;

                    case 0x001A:
                        ch = 0x3F;
                        break;

                    case 0x001B:
                        ch = 0x27;
                        break;

                    case 0x0020:
                        ch = 0x40;
                        break;

                    case 0x0021:
                        ch = 0x4F;
                        break;

                    case 0x0022:
                        ch = 0x7F;
                        break;

                    case 0x0023:
                        ch = 0x7B;
                        break;

                    case 0x0024:
                        ch = 0x5B;
                        break;

                    case 0x0025:
                        ch = 0x6C;
                        break;

                    case 0x0026:
                        ch = 0x50;
                        break;

                    case 0x0027:
                        ch = 0x7D;
                        break;

                    case 0x0028:
                        ch = 0x4D;
                        break;

                    case 0x0029:
                        ch = 0x5D;
                        break;

                    case 0x002A:
                        ch = 0x5C;
                        break;

                    case 0x002B:
                        ch = 0x4E;
                        break;

                    case 0x002C:
                        ch = 0x6B;
                        break;

                    case 0x002D:
                        ch = 0x60;
                        break;

                    case 0x002E:
                        ch = 0x4B;
                        break;

                    case 0x002F:
                        ch = 0x61;
                        break;

                    case 0x0030:
                    case 0x0031:
                    case 0x0032:
                    case 0x0033:
                    case 0x0034:
                    case 0x0035:
                    case 0x0036:
                    case 0x0037:
                    case 0x0038:
                    case 0x0039:
                        ch += 0x00C0;
                        break;

                    case 0x003A:
                        ch = 0x7A;
                        break;

                    case 0x003B:
                        ch = 0x5E;
                        break;

                    case 0x003C:
                        ch = 0x4C;
                        break;

                    case 0x003D:
                        ch = 0x7E;
                        break;

                    case 0x003E:
                        ch = 0x6E;
                        break;

                    case 0x003F:
                        ch = 0x6F;
                        break;

                    case 0x0040:
                        ch = 0x7C;
                        break;

                    case 0x0041:
                    case 0x0042:
                    case 0x0043:
                    case 0x0044:
                    case 0x0045:
                    case 0x0046:
                    case 0x0047:
                    case 0x0048:
                    case 0x0049:
                        ch += 0x0080;
                        break;

                    case 0x004A:
                    case 0x004B:
                    case 0x004C:
                    case 0x004D:
                    case 0x004E:
                    case 0x004F:
                    case 0x0050:
                    case 0x0051:
                    case 0x0052:
                        ch += 0x0087;
                        break;

                    case 0x0053:
                    case 0x0054:
                    case 0x0055:
                    case 0x0056:
                    case 0x0057:
                    case 0x0058:
                    case 0x0059:
                    case 0x005A:
                        ch += 0x008F;
                        break;

                    case 0x005B:
                        ch = 0x4A;
                        break;

                    case 0x005C:
                        ch = 0xE0;
                        break;

                    case 0x005D:
                        ch = 0x5A;
                        break;

                    case 0x005E:
                        ch = 0x5F;
                        break;

                    case 0x005F:
                        ch = 0x6D;
                        break;

                    case 0x0060:
                        ch = 0x79;
                        break;

                    case 0x0061:
                    case 0x0062:
                    case 0x0063:
                    case 0x0064:
                    case 0x0065:
                    case 0x0066:
                    case 0x0067:
                    case 0x0068:
                    case 0x0069:
                        ch += 0x0020;
                        break;

                    case 0x006A:
                    case 0x006B:
                    case 0x006C:
                    case 0x006D:
                    case 0x006E:
                    case 0x006F:
                    case 0x0070:
                    case 0x0071:
                    case 0x0072:
                        ch += 0x0027;
                        break;

                    case 0x0073:
                    case 0x0074:
                    case 0x0075:
                    case 0x0076:
                    case 0x0077:
                    case 0x0078:
                    case 0x0079:
                    case 0x007A:
                        ch += 0x002F;
                        break;

                    case 0x007B:
                        ch = 0xC0;
                        break;

                    case 0x007C:
                        ch = 0x6A;
                        break;

                    case 0x007D:
                        ch = 0xD0;
                        break;

                    case 0x007E:
                        ch = 0xA1;
                        break;

                    case 0x007F:
                        ch = 0x07;
                        break;

                    case 0x0080:
                    case 0x0081:
                    case 0x0082:
                    case 0x0083:
                    case 0x0084:
                        ch -= 0x0060;
                        break;

                    case 0x0085:
                        ch = 0x15;
                        break;

                    case 0x0086:
                        ch = 0x06;
                        break;

                    case 0x0087:
                        ch = 0x17;
                        break;

                    case 0x0088:
                    case 0x0089:
                    case 0x008A:
                    case 0x008B:
                    case 0x008C:
                        ch -= 0x0060;
                        break;

                    case 0x008D:
                        ch = 0x09;
                        break;

                    case 0x008E:
                        ch = 0x0A;
                        break;

                    case 0x008F:
                        ch = 0x1B;
                        break;

                    case 0x0090:
                        ch = 0x30;
                        break;

                    case 0x0091:
                        ch = 0x31;
                        break;

                    case 0x0092:
                        ch = 0x1A;
                        break;

                    case 0x0093:
                    case 0x0094:
                    case 0x0095:
                    case 0x0096:
                        ch -= 0x0060;
                        break;

                    case 0x0097:
                        ch = 0x08;
                        break;

                    case 0x0098:
                    case 0x0099:
                    case 0x009A:
                    case 0x009B:
                        ch -= 0x0060;
                        break;

                    case 0x009C:
                        ch = 0x04;
                        break;

                    case 0x009D:
                        ch = 0x14;
                        break;

                    case 0x009E:
                        ch = 0x3E;
                        break;

                    case 0x009F:
                        ch = 0xFF;
                        break;

                    case 0x00A0:
                        ch = 0x41;
                        break;

                    case 0x00A7:
                        ch = 0xE1;
                        break;

                    case 0x00AD:
                        ch = 0x73;
                        break;

                    case 0x0401:
                        ch = 0x63;
                        break;

                    case 0x0402:
                        ch = 0x59;
                        break;

                    case 0x0403:
                        ch = 0x62;
                        break;

                    case 0x0404:
                    case 0x0405:
                    case 0x0406:
                    case 0x0407:
                    case 0x0408:
                    case 0x0409:
                        ch -= 0x03A0;
                        break;

                    case 0x040A:
                        ch = 0x70;
                        break;

                    case 0x040B:
                        ch = 0x71;
                        break;

                    case 0x040C:
                        ch = 0x72;
                        break;

                    case 0x040E:
                        ch = 0x74;
                        break;

                    case 0x040F:
                        ch = 0x75;
                        break;

                    case 0x0410:
                        ch = 0xB9;
                        break;

                    case 0x0411:
                        ch = 0xBA;
                        break;

                    case 0x0412:
                        ch = 0xED;
                        break;

                    case 0x0413:
                        ch = 0xBF;
                        break;

                    case 0x0414:
                        ch = 0xBC;
                        break;

                    case 0x0415:
                        ch = 0xBD;
                        break;

                    case 0x0416:
                        ch = 0xEC;
                        break;

                    case 0x0417:
                        ch = 0xFA;
                        break;

                    case 0x0418:
                    case 0x0419:
                    case 0x041A:
                    case 0x041B:
                    case 0x041C:
                        ch -= 0x034D;
                        break;

                    case 0x041D:
                        ch = 0xDA;
                        break;

                    case 0x041E:
                        ch = 0xDB;
                        break;

                    case 0x041F:
                        ch = 0xDC;
                        break;

                    case 0x0420:
                        ch = 0xDE;
                        break;

                    case 0x0421:
                        ch = 0xDF;
                        break;

                    case 0x0422:
                        ch = 0xEA;
                        break;

                    case 0x0423:
                        ch = 0xEB;
                        break;

                    case 0x0424:
                        ch = 0xBE;
                        break;

                    case 0x0425:
                        ch = 0xCA;
                        break;

                    case 0x0426:
                        ch = 0xBB;
                        break;

                    case 0x0427:
                        ch = 0xFE;
                        break;

                    case 0x0428:
                        ch = 0xFB;
                        break;

                    case 0x0429:
                        ch = 0xFD;
                        break;

                    case 0x042A:
                        ch = 0x57;
                        break;

                    case 0x042B:
                        ch = 0xEF;
                        break;

                    case 0x042C:
                        ch = 0xEE;
                        break;

                    case 0x042D:
                        ch = 0xFC;
                        break;

                    case 0x042E:
                        ch = 0xB8;
                        break;

                    case 0x042F:
                        ch = 0xDD;
                        break;

                    case 0x0430:
                        ch = 0x77;
                        break;

                    case 0x0431:
                        ch = 0x78;
                        break;

                    case 0x0432:
                        ch = 0xAF;
                        break;

                    case 0x0433:
                        ch = 0x8D;
                        break;

                    case 0x0434:
                        ch = 0x8A;
                        break;

                    case 0x0435:
                        ch = 0x8B;
                        break;

                    case 0x0436:
                        ch = 0xAE;
                        break;

                    case 0x0437:
                        ch = 0xB2;
                        break;

                    case 0x0438:
                        ch = 0x8F;
                        break;

                    case 0x0439:
                        ch = 0x90;
                        break;

                    case 0x043A:
                    case 0x043B:
                    case 0x043C:
                    case 0x043D:
                    case 0x043E:
                    case 0x043F:
                        ch -= 0x03A0;
                        break;

                    case 0x0440:
                    case 0x0441:
                    case 0x0442:
                    case 0x0443:
                        ch -= 0x0396;
                        break;

                    case 0x0444:
                        ch = 0x8C;
                        break;

                    case 0x0445:
                        ch = 0x8E;
                        break;

                    case 0x0446:
                        ch = 0x80;
                        break;

                    case 0x0447:
                        ch = 0xB6;
                        break;

                    case 0x0448:
                        ch = 0xB3;
                        break;

                    case 0x0449:
                        ch = 0xB5;
                        break;

                    case 0x044A:
                        ch = 0xB7;
                        break;

                    case 0x044B:
                        ch = 0xB1;
                        break;

                    case 0x044C:
                        ch = 0xB0;
                        break;

                    case 0x044D:
                        ch = 0xB4;
                        break;

                    case 0x044E:
                        ch = 0x76;
                        break;

                    case 0x044F:
                        ch = 0xA0;
                        break;

                    case 0x0451:
                        ch = 0x44;
                        break;

                    case 0x0452:
                        ch = 0x42;
                        break;

                    case 0x0453:
                        ch = 0x43;
                        break;

                    case 0x0454:
                    case 0x0455:
                    case 0x0456:
                    case 0x0457:
                    case 0x0458:
                        ch -= 0x040F;
                        break;

                    case 0x0459:
                    case 0x045A:
                    case 0x045B:
                    case 0x045C:
                        ch -= 0x0408;
                        break;

                    case 0x045E:
                        ch = 0x55;
                        break;

                    case 0x045F:
                        ch = 0x56;
                        break;

                    case 0x2116:
                        ch = 0x58;
                        break;

                    case 0xFF01:
                        ch = 0x4F;
                        break;

                    case 0xFF02:
                        ch = 0x7F;
                        break;

                    case 0xFF03:
                        ch = 0x7B;
                        break;

                    case 0xFF04:
                        ch = 0x5B;
                        break;

                    case 0xFF05:
                        ch = 0x6C;
                        break;

                    case 0xFF06:
                        ch = 0x50;
                        break;

                    case 0xFF07:
                        ch = 0x7D;
                        break;

                    case 0xFF08:
                        ch = 0x4D;
                        break;

                    case 0xFF09:
                        ch = 0x5D;
                        break;

                    case 0xFF0A:
                        ch = 0x5C;
                        break;

                    case 0xFF0B:
                        ch = 0x4E;
                        break;

                    case 0xFF0C:
                        ch = 0x6B;
                        break;

                    case 0xFF0D:
                        ch = 0x60;
                        break;

                    case 0xFF0E:
                        ch = 0x4B;
                        break;

                    case 0xFF0F:
                        ch = 0x61;
                        break;

                    case 0xFF10:
                    case 0xFF11:
                    case 0xFF12:
                    case 0xFF13:
                    case 0xFF14:
                    case 0xFF15:
                    case 0xFF16:
                    case 0xFF17:
                    case 0xFF18:
                    case 0xFF19:
                        ch -= 0xFE20;
                        break;

                    case 0xFF1A:
                        ch = 0x7A;
                        break;

                    case 0xFF1B:
                        ch = 0x5E;
                        break;

                    case 0xFF1C:
                        ch = 0x4C;
                        break;

                    case 0xFF1D:
                        ch = 0x7E;
                        break;

                    case 0xFF1E:
                        ch = 0x6E;
                        break;

                    case 0xFF1F:
                        ch = 0x6F;
                        break;

                    case 0xFF20:
                        ch = 0x7C;
                        break;

                    case 0xFF21:
                    case 0xFF22:
                    case 0xFF23:
                    case 0xFF24:
                    case 0xFF25:
                    case 0xFF26:
                    case 0xFF27:
                    case 0xFF28:
                    case 0xFF29:
                        ch -= 0xFE60;
                        break;

                    case 0xFF2A:
                    case 0xFF2B:
                    case 0xFF2C:
                    case 0xFF2D:
                    case 0xFF2E:
                    case 0xFF2F:
                    case 0xFF30:
                    case 0xFF31:
                    case 0xFF32:
                        ch -= 0xFE59;
                        break;

                    case 0xFF33:
                    case 0xFF34:
                    case 0xFF35:
                    case 0xFF36:
                    case 0xFF37:
                    case 0xFF38:
                    case 0xFF39:
                    case 0xFF3A:
                        ch -= 0xFE51;
                        break;

                    case 0xFF3B:
                        ch = 0x4A;
                        break;

                    case 0xFF3C:
                        ch = 0xE0;
                        break;

                    case 0xFF3D:
                        ch = 0x5A;
                        break;

                    case 0xFF3E:
                        ch = 0x5F;
                        break;

                    case 0xFF3F:
                        ch = 0x6D;
                        break;

                    case 0xFF40:
                        ch = 0x79;
                        break;

                    case 0xFF41:
                    case 0xFF42:
                    case 0xFF43:
                    case 0xFF44:
                    case 0xFF45:
                    case 0xFF46:
                    case 0xFF47:
                    case 0xFF48:
                    case 0xFF49:
                        ch -= 0xFEC0;
                        break;

                    case 0xFF4A:
                    case 0xFF4B:
                    case 0xFF4C:
                    case 0xFF4D:
                    case 0xFF4E:
                    case 0xFF4F:
                    case 0xFF50:
                    case 0xFF51:
                    case 0xFF52:
                        ch -= 0xFEB9;
                        break;

                    case 0xFF53:
                    case 0xFF54:
                    case 0xFF55:
                    case 0xFF56:
                    case 0xFF57:
                    case 0xFF58:
                    case 0xFF59:
                    case 0xFF5A:
                        ch -= 0xFEB1;
                        break;

                    case 0xFF5B:
                        ch = 0xC0;
                        break;

                    case 0xFF5C:
                        ch = 0x6A;
                        break;

                    case 0xFF5D:
                        ch = 0xD0;
                        break;

                    case 0xFF5E:
                        ch = 0xA1;
                        break;

                    default:
                        HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                        continue;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #17
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 161)
                {
                    switch (ch)
                    {
                    case 0x00A2:
                    case 0x00A3:
                    case 0x00A4:
                    case 0x00A5:
                    case 0x00A6:
                    case 0x00A7:
                    case 0x00A8:
                    case 0x00A9:
                    case 0x00AB:
                    case 0x00AC:
                    case 0x00AD:
                    case 0x00AE:
                    case 0x00B0:
                    case 0x00B1:
                    case 0x00B2:
                    case 0x00B3:
                    case 0x00B4:
                    case 0x00B5:
                    case 0x00B6:
                    case 0x00B8:
                    case 0x00B9:
                    case 0x00BB:
                    case 0x00BC:
                    case 0x00BD:
                    case 0x00BE:
                        break;

                    case 0x00D7:
                        ch = 0xAA;
                        break;

                    case 0x00F7:
                        ch = 0xBA;
                        break;

                    case 0x05D0:
                    case 0x05D1:
                    case 0x05D2:
                    case 0x05D3:
                    case 0x05D4:
                    case 0x05D5:
                    case 0x05D6:
                    case 0x05D7:
                    case 0x05D8:
                    case 0x05D9:
                    case 0x05DA:
                    case 0x05DB:
                    case 0x05DC:
                    case 0x05DD:
                    case 0x05DE:
                    case 0x05DF:
                    case 0x05E0:
                    case 0x05E1:
                    case 0x05E2:
                    case 0x05E3:
                    case 0x05E4:
                    case 0x05E5:
                    case 0x05E6:
                    case 0x05E7:
                    case 0x05E8:
                    case 0x05E9:
                    case 0x05EA:
                        ch -= 0x04F0;
                        break;

                    case 0x2017:
                        ch = 0xDF;
                        break;

                    case 0x2022:
                        ch = 0xB7;
                        break;

                    case 0x203E:
                        ch = 0xAF;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #18
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 161)
                {
                    switch (ch)
                    {
                    case 0x00AD:
                        break;

                    case 0x00A7:
                        ch = 0xFD;
                        break;

                    case 0x0401:
                    case 0x0402:
                    case 0x0403:
                    case 0x0404:
                    case 0x0405:
                    case 0x0406:
                    case 0x0407:
                    case 0x0408:
                    case 0x0409:
                    case 0x040A:
                    case 0x040B:
                    case 0x040C:
                        ch -= 0x0360;
                        break;

                    case 0x040E:
                    case 0x040F:
                    case 0x0410:
                    case 0x0411:
                    case 0x0412:
                    case 0x0413:
                    case 0x0414:
                    case 0x0415:
                    case 0x0416:
                    case 0x0417:
                    case 0x0418:
                    case 0x0419:
                    case 0x041A:
                    case 0x041B:
                    case 0x041C:
                    case 0x041D:
                    case 0x041E:
                    case 0x041F:
                    case 0x0420:
                    case 0x0421:
                    case 0x0422:
                    case 0x0423:
                    case 0x0424:
                    case 0x0425:
                    case 0x0426:
                    case 0x0427:
                    case 0x0428:
                    case 0x0429:
                    case 0x042A:
                    case 0x042B:
                    case 0x042C:
                    case 0x042D:
                    case 0x042E:
                    case 0x042F:
                    case 0x0430:
                    case 0x0431:
                    case 0x0432:
                    case 0x0433:
                    case 0x0434:
                    case 0x0435:
                    case 0x0436:
                    case 0x0437:
                    case 0x0438:
                    case 0x0439:
                    case 0x043A:
                    case 0x043B:
                    case 0x043C:
                    case 0x043D:
                    case 0x043E:
                    case 0x043F:
                    case 0x0440:
                    case 0x0441:
                    case 0x0442:
                    case 0x0443:
                    case 0x0444:
                    case 0x0445:
                    case 0x0446:
                    case 0x0447:
                    case 0x0448:
                    case 0x0449:
                    case 0x044A:
                    case 0x044B:
                    case 0x044C:
                    case 0x044D:
                    case 0x044E:
                    case 0x044F:
                        ch -= 0x0360;
                        break;

                    case 0x0451:
                    case 0x0452:
                    case 0x0453:
                    case 0x0454:
                    case 0x0455:
                    case 0x0456:
                    case 0x0457:
                    case 0x0458:
                    case 0x0459:
                    case 0x045A:
                    case 0x045B:
                    case 0x045C:
                        ch -= 0x0360;
                        break;

                    case 0x045E:
                        ch = 0xFE;
                        break;

                    case 0x045F:
                        ch = 0xFF;
                        break;

                    case 0x2116:
                        ch = 0xF0;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #19
0
        unsafe static int InternalGetBytes(char *chars, int count, byte *bytes, int bcount, EncoderFallback fallback, ref EncoderFallbackBuffer buffer, ref char leftOver, bool flush)
        {
            byte *end_bytes   = bytes + bcount;
            byte *start_bytes = bytes;
            char *end         = chars + count;
            char *start       = chars;

            while (chars < end)
            {
                if (leftOver == 0)
                {
                    for (; chars < end; chars++)
                    {
                        int ch = *chars;
                        if (ch < '\x80')
                        {
                            if (bytes >= end_bytes)
                            {
                                goto fail_no_space;
                            }
                            *bytes++ = (byte)ch;
                        }
                        else if (ch < '\x800')
                        {
                            if (bytes + 1 >= end_bytes)
                            {
                                goto fail_no_space;
                            }
                            bytes[0] = (byte)(0xC0 | (ch >> 6));
                            bytes[1] = (byte)(0x80 | (ch & 0x3F));
                            bytes   += 2;
                        }
                        else if (ch < '\uD800' || ch > '\uDFFF')
                        {
                            if (bytes + 2 >= end_bytes)
                            {
                                goto fail_no_space;
                            }
                            bytes[0] = (byte)(0xE0 | (ch >> 12));
                            bytes[1] = (byte)(0x80 | ((ch >> 6) & 0x3F));
                            bytes[2] = (byte)(0x80 | (ch & 0x3F));
                            bytes   += 3;
                        }
                        else if (ch <= '\uDBFF')
                        {
                            // This is a surrogate char, exit the inner loop.
                            leftOver = *chars;
                            chars++;
                            break;
                        }
                        else
                        {
                            // We have a surrogate tail without
                            // leading surrogate.
                            char[] fallback_chars = GetFallbackChars(chars, start, fallback, ref buffer);
                            char   dummy          = '\0';
                            if (bytes + InternalGetByteCount(fallback_chars, 0, fallback_chars.Length, fallback, ref dummy, true) > end_bytes)
                                goto fail_no_space;
                            fixed(char *fb_chars = fallback_chars)
                            {
                                bytes += InternalGetBytes(fb_chars, fallback_chars.Length, bytes, bcount - (int)(bytes - start_bytes), fallback, ref buffer, ref dummy, true);
                            }

                            leftOver = '\0';
                        }
                    }
                }
                else
                {
                    if (*chars >= '\uDC00' && *chars <= '\uDFFF')
                    {
                        // We have a correct surrogate pair.
                        int ch = 0x10000 + (int)*chars - 0xDC00 + (((int)leftOver - 0xD800) << 10);
                        if (bytes + 3 >= end_bytes)
                        {
                            goto fail_no_space;
                        }
                        bytes[0] = (byte)(0xF0 | (ch >> 18));
                        bytes[1] = (byte)(0x80 | ((ch >> 12) & 0x3F));
                        bytes[2] = (byte)(0x80 | ((ch >> 6) & 0x3F));
                        bytes[3] = (byte)(0x80 | (ch & 0x3F));
                        bytes   += 4;
                        chars++;
                    }
                    else
                    {
                        // We have a surrogate start followed by a
                        // regular character.  Technically, this is
                        // invalid, but we have to do something.
                        // We write out the surrogate start and then
                        // re-visit the current character again.
                        char[] fallback_chars = GetFallbackChars(chars, start, fallback, ref buffer);
                        char   dummy          = '\0';

                        if (bytes + InternalGetByteCount(fallback_chars, 0, fallback_chars.Length, fallback, ref dummy, true) > end_bytes)
                        {
                            goto fail_no_space;

                            fixed(char *fb_chars = fallback_chars)
                            {
                                InternalGetBytes(fb_chars, fallback_chars.Length, bytes, bcount - (int)(bytes - start_bytes), fallback, ref buffer, ref dummy, true);
                            }

                            leftOver = '\0';
                    }

                    leftOver = '\0';
                }
            }
            if (flush)
            {
                // Flush the left-over surrogate pair start.
                if (leftOver != '\0')
                {
                    int ch = leftOver;
                    if (bytes + 2 < end_bytes)
                    {
                        bytes[0] = (byte)(0xE0 | (ch >> 12));
                        bytes[1] = (byte)(0x80 | ((ch >> 6) & 0x3F));
                        bytes[2] = (byte)(0x80 | (ch & 0x3F));
                        bytes   += 3;
                    }
                    else
                    {
                        goto fail_no_space;
                    }

                    leftOver = '\0';
                }
            }

            return((int)(bytes - (end_bytes - bcount)));

fail_no_space:
            throw new ArgumentException("Insufficient Space", "bytes");
        }
コード例 #20
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 161)
                {
                    switch (ch)
                    {
                    case 0x00A3:
                    case 0x00A4:
                    case 0x00A7:
                    case 0x00A8:
                    case 0x00AD:
                    case 0x00B0:
                    case 0x00B2:
                    case 0x00B3:
                    case 0x00B4:
                    case 0x00B5:
                    case 0x00B7:
                    case 0x00B8:
                    case 0x00BD:
                    case 0x00C0:
                    case 0x00C1:
                    case 0x00C2:
                    case 0x00C4:
                    case 0x00C7:
                    case 0x00C8:
                    case 0x00C9:
                    case 0x00CA:
                    case 0x00CB:
                    case 0x00CC:
                    case 0x00CD:
                    case 0x00CE:
                    case 0x00CF:
                    case 0x00D1:
                    case 0x00D2:
                    case 0x00D3:
                    case 0x00D4:
                    case 0x00D6:
                    case 0x00D7:
                    case 0x00D9:
                    case 0x00DA:
                    case 0x00DB:
                    case 0x00DC:
                    case 0x00DF:
                    case 0x00E0:
                    case 0x00E1:
                    case 0x00E2:
                    case 0x00E4:
                    case 0x00E7:
                    case 0x00E8:
                    case 0x00E9:
                    case 0x00EA:
                    case 0x00EB:
                    case 0x00EC:
                    case 0x00ED:
                    case 0x00EE:
                    case 0x00EF:
                    case 0x00F1:
                    case 0x00F2:
                    case 0x00F3:
                    case 0x00F4:
                    case 0x00F6:
                    case 0x00F7:
                    case 0x00F9:
                    case 0x00FA:
                    case 0x00FB:
                    case 0x00FC:
                        break;

                    case 0x0108:
                        ch = 0xC6;
                        break;

                    case 0x0109:
                        ch = 0xE6;
                        break;

                    case 0x010A:
                        ch = 0xC5;
                        break;

                    case 0x010B:
                        ch = 0xE5;
                        break;

                    case 0x011C:
                        ch = 0xD8;
                        break;

                    case 0x011D:
                        ch = 0xF8;
                        break;

                    case 0x011E:
                        ch = 0xAB;
                        break;

                    case 0x011F:
                        ch = 0xBB;
                        break;

                    case 0x0120:
                        ch = 0xD5;
                        break;

                    case 0x0121:
                        ch = 0xF5;
                        break;

                    case 0x0124:
                        ch = 0xA6;
                        break;

                    case 0x0125:
                        ch = 0xB6;
                        break;

                    case 0x0126:
                        ch = 0xA1;
                        break;

                    case 0x0127:
                        ch = 0xB1;
                        break;

                    case 0x0130:
                        ch = 0xA9;
                        break;

                    case 0x0131:
                        ch = 0xB9;
                        break;

                    case 0x0134:
                        ch = 0xAC;
                        break;

                    case 0x0135:
                        ch = 0xBC;
                        break;

                    case 0x015C:
                        ch = 0xDE;
                        break;

                    case 0x015D:
                        ch = 0xFE;
                        break;

                    case 0x015E:
                        ch = 0xAA;
                        break;

                    case 0x015F:
                        ch = 0xBA;
                        break;

                    case 0x016C:
                        ch = 0xDD;
                        break;

                    case 0x016D:
                        ch = 0xFD;
                        break;

                    case 0x017B:
                        ch = 0xAF;
                        break;

                    case 0x017C:
                        ch = 0xBF;
                        break;

                    case 0x02D8:
                        ch = 0xA2;
                        break;

                    case 0x02D9:
                        ch = 0xFF;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #21
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 128)
                {
                    switch (ch)
                    {
                    case 0x0081:
                    case 0x008A:
                    case 0x008C:
                    case 0x008D:
                    case 0x008E:
                    case 0x008F:
                    case 0x0090:
                    case 0x009A:
                    case 0x009C:
                    case 0x009D:
                    case 0x009E:
                    case 0x009F:
                    case 0x00A0:
                    case 0x00A1:
                    case 0x00A2:
                    case 0x00A3:
                    case 0x00A5:
                    case 0x00A6:
                    case 0x00A7:
                    case 0x00A8:
                    case 0x00A9:
                    case 0x00AB:
                    case 0x00AC:
                    case 0x00AD:
                    case 0x00AE:
                    case 0x00AF:
                    case 0x00B0:
                    case 0x00B1:
                    case 0x00B2:
                    case 0x00B3:
                    case 0x00B4:
                    case 0x00B5:
                    case 0x00B6:
                    case 0x00B7:
                    case 0x00B8:
                    case 0x00B9:
                    case 0x00BB:
                    case 0x00BC:
                    case 0x00BD:
                    case 0x00BE:
                    case 0x00BF:
                        break;

                    case 0x00D7:
                        ch = 0xAA;
                        break;

                    case 0x00F7:
                        ch = 0xBA;
                        break;

                    case 0x0192:
                        ch = 0x83;
                        break;

                    case 0x02C6:
                        ch = 0x88;
                        break;

                    case 0x02DC:
                        ch = 0x98;
                        break;

                    case 0x05B0:
                    case 0x05B1:
                    case 0x05B2:
                    case 0x05B3:
                    case 0x05B4:
                    case 0x05B5:
                    case 0x05B6:
                    case 0x05B7:
                    case 0x05B8:
                    case 0x05B9:
                        ch -= 0x04F0;
                        break;

                    case 0x05BB:
                    case 0x05BC:
                    case 0x05BD:
                    case 0x05BE:
                    case 0x05BF:
                    case 0x05C0:
                    case 0x05C1:
                    case 0x05C2:
                    case 0x05C3:
                        ch -= 0x04F0;
                        break;

                    case 0x05D0:
                    case 0x05D1:
                    case 0x05D2:
                    case 0x05D3:
                    case 0x05D4:
                    case 0x05D5:
                    case 0x05D6:
                    case 0x05D7:
                    case 0x05D8:
                    case 0x05D9:
                    case 0x05DA:
                    case 0x05DB:
                    case 0x05DC:
                    case 0x05DD:
                    case 0x05DE:
                    case 0x05DF:
                    case 0x05E0:
                    case 0x05E1:
                    case 0x05E2:
                    case 0x05E3:
                    case 0x05E4:
                    case 0x05E5:
                    case 0x05E6:
                    case 0x05E7:
                    case 0x05E8:
                    case 0x05E9:
                    case 0x05EA:
                        ch -= 0x04F0;
                        break;

                    case 0x05F0:
                    case 0x05F1:
                    case 0x05F2:
                    case 0x05F3:
                    case 0x05F4:
                        ch -= 0x051C;
                        break;

                    case 0x200E:
                        ch = 0xFD;
                        break;

                    case 0x200F:
                        ch = 0xFE;
                        break;

                    case 0x2013:
                        ch = 0x96;
                        break;

                    case 0x2014:
                        ch = 0x97;
                        break;

                    case 0x2018:
                        ch = 0x91;
                        break;

                    case 0x2019:
                        ch = 0x92;
                        break;

                    case 0x201A:
                        ch = 0x82;
                        break;

                    case 0x201C:
                        ch = 0x93;
                        break;

                    case 0x201D:
                        ch = 0x94;
                        break;

                    case 0x201E:
                        ch = 0x84;
                        break;

                    case 0x2020:
                        ch = 0x86;
                        break;

                    case 0x2021:
                        ch = 0x87;
                        break;

                    case 0x2022:
                        ch = 0x95;
                        break;

                    case 0x2026:
                        ch = 0x85;
                        break;

                    case 0x2030:
                        ch = 0x89;
                        break;

                    case 0x2039:
                        ch = 0x8B;
                        break;

                    case 0x203A:
                        ch = 0x9B;
                        break;

                    case 0x20AA:
                        ch = 0xA4;
                        break;

                    case 0x20AC:
                        ch = 0x80;
                        break;

                    case 0x2122:
                        ch = 0x99;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #22
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 128)
                {
                    switch (ch)
                    {
                    case 0x0098:
                    case 0x00A0:
                    case 0x00A4:
                    case 0x00A6:
                    case 0x00A7:
                    case 0x00A9:
                    case 0x00AB:
                    case 0x00AC:
                    case 0x00AD:
                    case 0x00AE:
                    case 0x00B0:
                    case 0x00B1:
                    case 0x00B5:
                    case 0x00B6:
                    case 0x00B7:
                    case 0x00BB:
                        break;

                    case 0x0401:
                        ch = 0xA8;
                        break;

                    case 0x0402:
                        ch = 0x80;
                        break;

                    case 0x0403:
                        ch = 0x81;
                        break;

                    case 0x0404:
                        ch = 0xAA;
                        break;

                    case 0x0405:
                        ch = 0xBD;
                        break;

                    case 0x0406:
                        ch = 0xB2;
                        break;

                    case 0x0407:
                        ch = 0xAF;
                        break;

                    case 0x0408:
                        ch = 0xA3;
                        break;

                    case 0x0409:
                        ch = 0x8A;
                        break;

                    case 0x040A:
                        ch = 0x8C;
                        break;

                    case 0x040B:
                        ch = 0x8E;
                        break;

                    case 0x040C:
                        ch = 0x8D;
                        break;

                    case 0x040E:
                        ch = 0xA1;
                        break;

                    case 0x040F:
                        ch = 0x8F;
                        break;

                    case 0x0410:
                    case 0x0411:
                    case 0x0412:
                    case 0x0413:
                    case 0x0414:
                    case 0x0415:
                    case 0x0416:
                    case 0x0417:
                    case 0x0418:
                    case 0x0419:
                    case 0x041A:
                    case 0x041B:
                    case 0x041C:
                    case 0x041D:
                    case 0x041E:
                    case 0x041F:
                    case 0x0420:
                    case 0x0421:
                    case 0x0422:
                    case 0x0423:
                    case 0x0424:
                    case 0x0425:
                    case 0x0426:
                    case 0x0427:
                    case 0x0428:
                    case 0x0429:
                    case 0x042A:
                    case 0x042B:
                    case 0x042C:
                    case 0x042D:
                    case 0x042E:
                    case 0x042F:
                    case 0x0430:
                    case 0x0431:
                    case 0x0432:
                    case 0x0433:
                    case 0x0434:
                    case 0x0435:
                    case 0x0436:
                    case 0x0437:
                    case 0x0438:
                    case 0x0439:
                    case 0x043A:
                    case 0x043B:
                    case 0x043C:
                    case 0x043D:
                    case 0x043E:
                    case 0x043F:
                    case 0x0440:
                    case 0x0441:
                    case 0x0442:
                    case 0x0443:
                    case 0x0444:
                    case 0x0445:
                    case 0x0446:
                    case 0x0447:
                    case 0x0448:
                    case 0x0449:
                    case 0x044A:
                    case 0x044B:
                    case 0x044C:
                    case 0x044D:
                    case 0x044E:
                    case 0x044F:
                        ch -= 0x0350;
                        break;

                    case 0x0451:
                        ch = 0xB8;
                        break;

                    case 0x0452:
                        ch = 0x90;
                        break;

                    case 0x0453:
                        ch = 0x83;
                        break;

                    case 0x0454:
                        ch = 0xBA;
                        break;

                    case 0x0455:
                        ch = 0xBE;
                        break;

                    case 0x0456:
                        ch = 0xB3;
                        break;

                    case 0x0457:
                        ch = 0xBF;
                        break;

                    case 0x0458:
                        ch = 0xBC;
                        break;

                    case 0x0459:
                        ch = 0x9A;
                        break;

                    case 0x045A:
                        ch = 0x9C;
                        break;

                    case 0x045B:
                        ch = 0x9E;
                        break;

                    case 0x045C:
                        ch = 0x9D;
                        break;

                    case 0x045E:
                        ch = 0xA2;
                        break;

                    case 0x045F:
                        ch = 0x9F;
                        break;

                    case 0x0490:
                        ch = 0xA5;
                        break;

                    case 0x0491:
                        ch = 0xB4;
                        break;

                    case 0x2013:
                        ch = 0x96;
                        break;

                    case 0x2014:
                        ch = 0x97;
                        break;

                    case 0x2018:
                        ch = 0x91;
                        break;

                    case 0x2019:
                        ch = 0x92;
                        break;

                    case 0x201A:
                        ch = 0x82;
                        break;

                    case 0x201C:
                        ch = 0x93;
                        break;

                    case 0x201D:
                        ch = 0x94;
                        break;

                    case 0x201E:
                        ch = 0x84;
                        break;

                    case 0x2020:
                        ch = 0x86;
                        break;

                    case 0x2021:
                        ch = 0x87;
                        break;

                    case 0x2022:
                        ch = 0x95;
                        break;

                    case 0x2026:
                        ch = 0x85;
                        break;

                    case 0x2030:
                        ch = 0x89;
                        break;

                    case 0x2039:
                        ch = 0x8B;
                        break;

                    case 0x203A:
                        ch = 0x9B;
                        break;

                    case 0x20AC:
                        ch = 0x88;
                        break;

                    case 0x2116:
                        ch = 0xB9;
                        break;

                    case 0x2122:
                        ch = 0x99;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #23
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 4)
                {
                    switch (ch)
                    {
                    case 0x000B:
                    case 0x000C:
                    case 0x000D:
                    case 0x000E:
                    case 0x000F:
                    case 0x0010:
                    case 0x0011:
                    case 0x0012:
                    case 0x0013:
                    case 0x0018:
                    case 0x0019:
                    case 0x001C:
                    case 0x001D:
                    case 0x001E:
                    case 0x001F:
                        break;

                    case 0x0004:
                        ch = 0x37;
                        break;

                    case 0x0005:
                        ch = 0x2D;
                        break;

                    case 0x0006:
                        ch = 0x2E;
                        break;

                    case 0x0007:
                        ch = 0x2F;
                        break;

                    case 0x0008:
                        ch = 0x16;
                        break;

                    case 0x0009:
                        ch = 0x05;
                        break;

                    case 0x000A:
                        ch = 0x25;
                        break;

                    case 0x0014:
                        ch = 0x3C;
                        break;

                    case 0x0015:
                        ch = 0x3D;
                        break;

                    case 0x0016:
                        ch = 0x32;
                        break;

                    case 0x0017:
                        ch = 0x26;
                        break;

                    case 0x001A:
                        ch = 0x3F;
                        break;

                    case 0x001B:
                        ch = 0x27;
                        break;

                    case 0x0020:
                        ch = 0x40;
                        break;

                    case 0x0021:
                        ch = 0x5A;
                        break;

                    case 0x0022:
                        ch = 0x7F;
                        break;

                    case 0x0023:
                        ch = 0x7B;
                        break;

                    case 0x0024:
                        ch = 0x5B;
                        break;

                    case 0x0025:
                        ch = 0x6C;
                        break;

                    case 0x0026:
                        ch = 0x50;
                        break;

                    case 0x0027:
                        ch = 0x7D;
                        break;

                    case 0x0028:
                        ch = 0x4D;
                        break;

                    case 0x0029:
                        ch = 0x5D;
                        break;

                    case 0x002A:
                        ch = 0x5C;
                        break;

                    case 0x002B:
                        ch = 0x4E;
                        break;

                    case 0x002C:
                        ch = 0x6B;
                        break;

                    case 0x002D:
                        ch = 0x60;
                        break;

                    case 0x002E:
                        ch = 0x4B;
                        break;

                    case 0x002F:
                        ch = 0x61;
                        break;

                    case 0x0030:
                    case 0x0031:
                    case 0x0032:
                    case 0x0033:
                    case 0x0034:
                    case 0x0035:
                    case 0x0036:
                    case 0x0037:
                    case 0x0038:
                    case 0x0039:
                        ch += 0x00C0;
                        break;

                    case 0x003A:
                        ch = 0x7A;
                        break;

                    case 0x003B:
                        ch = 0x5E;
                        break;

                    case 0x003C:
                        ch = 0x4C;
                        break;

                    case 0x003D:
                        ch = 0x7E;
                        break;

                    case 0x003E:
                        ch = 0x6E;
                        break;

                    case 0x003F:
                        ch = 0x6F;
                        break;

                    case 0x0040:
                        ch = 0x7C;
                        break;

                    case 0x0041:
                    case 0x0042:
                    case 0x0043:
                    case 0x0044:
                    case 0x0045:
                    case 0x0046:
                    case 0x0047:
                    case 0x0048:
                    case 0x0049:
                        ch += 0x0080;
                        break;

                    case 0x004A:
                    case 0x004B:
                    case 0x004C:
                    case 0x004D:
                    case 0x004E:
                    case 0x004F:
                    case 0x0050:
                    case 0x0051:
                    case 0x0052:
                        ch += 0x0087;
                        break;

                    case 0x0053:
                    case 0x0054:
                    case 0x0055:
                    case 0x0056:
                    case 0x0057:
                    case 0x0058:
                    case 0x0059:
                    case 0x005A:
                        ch += 0x008F;
                        break;

                    case 0x005F:
                        ch = 0x6D;
                        break;

                    case 0x0061:
                    case 0x0062:
                    case 0x0063:
                    case 0x0064:
                    case 0x0065:
                    case 0x0066:
                    case 0x0067:
                    case 0x0068:
                    case 0x0069:
                        ch += 0x0020;
                        break;

                    case 0x006A:
                    case 0x006B:
                    case 0x006C:
                    case 0x006D:
                    case 0x006E:
                    case 0x006F:
                    case 0x0070:
                    case 0x0071:
                    case 0x0072:
                        ch += 0x0027;
                        break;

                    case 0x0073:
                    case 0x0074:
                    case 0x0075:
                    case 0x0076:
                    case 0x0077:
                    case 0x0078:
                    case 0x0079:
                    case 0x007A:
                        ch += 0x002F;
                        break;

                    case 0x007C:
                        ch = 0x4F;
                        break;

                    case 0x007F:
                        ch = 0x07;
                        break;

                    case 0x0080:
                    case 0x0081:
                    case 0x0082:
                    case 0x0083:
                    case 0x0084:
                        ch -= 0x0060;
                        break;

                    case 0x0085:
                        ch = 0x15;
                        break;

                    case 0x0086:
                        ch = 0x06;
                        break;

                    case 0x0087:
                        ch = 0x17;
                        break;

                    case 0x0088:
                    case 0x0089:
                    case 0x008A:
                    case 0x008B:
                    case 0x008C:
                        ch -= 0x0060;
                        break;

                    case 0x008D:
                        ch = 0x09;
                        break;

                    case 0x008E:
                        ch = 0x0A;
                        break;

                    case 0x008F:
                        ch = 0x1B;
                        break;

                    case 0x0090:
                        ch = 0x30;
                        break;

                    case 0x0091:
                        ch = 0x31;
                        break;

                    case 0x0092:
                        ch = 0x1A;
                        break;

                    case 0x0093:
                    case 0x0094:
                    case 0x0095:
                    case 0x0096:
                        ch -= 0x0060;
                        break;

                    case 0x0097:
                        ch = 0x08;
                        break;

                    case 0x0098:
                    case 0x0099:
                    case 0x009A:
                    case 0x009B:
                        ch -= 0x0060;
                        break;

                    case 0x009C:
                        ch = 0x04;
                        break;

                    case 0x009D:
                        ch = 0x14;
                        break;

                    case 0x009E:
                        ch = 0x3E;
                        break;

                    case 0x009F:
                        ch = 0xFF;
                        break;

                    case 0x00A0:
                        ch = 0x41;
                        break;

                    case 0x00A2:
                        ch = 0x4A;
                        break;

                    case 0x00A6:
                        ch = 0x6A;
                        break;

                    case 0x00AC:
                        ch = 0x5F;
                        break;

                    case 0x00AD:
                        ch = 0xCA;
                        break;

                    case 0x00D7:
                        ch = 0xE0;
                        break;

                    case 0x00F7:
                        ch = 0xA1;
                        break;

                    case 0x060C:
                        ch = 0x79;
                        break;

                    case 0x061B:
                        ch = 0xC0;
                        break;

                    case 0x061F:
                        ch = 0xD0;
                        break;

                    case 0x0621:
                        ch = 0x46;
                        break;

                    case 0x0622:
                        ch = 0x47;
                        break;

                    case 0x0623:
                        ch = 0x49;
                        break;

                    case 0x0624:
                        ch = 0x52;
                        break;

                    case 0x0625:
                        ch = 0x56;
                        break;

                    case 0x0626:
                        ch = 0x55;
                        break;

                    case 0x0627:
                        ch = 0x56;
                        break;

                    case 0x0628:
                        ch = 0x58;
                        break;

                    case 0x0629:
                        ch = 0x62;
                        break;

                    case 0x062A:
                        ch = 0x63;
                        break;

                    case 0x062B:
                        ch = 0x65;
                        break;

                    case 0x062C:
                        ch = 0x67;
                        break;

                    case 0x062D:
                        ch = 0x69;
                        break;

                    case 0x062E:
                        ch = 0x71;
                        break;

                    case 0x062F:
                    case 0x0630:
                    case 0x0631:
                    case 0x0632:
                    case 0x0633:
                        ch -= 0x05BC;
                        break;

                    case 0x0634:
                        ch = 0x80;
                        break;

                    case 0x0635:
                        ch = 0x8B;
                        break;

                    case 0x0636:
                        ch = 0x8D;
                        break;

                    case 0x0637:
                        ch = 0x8F;
                        break;

                    case 0x0638:
                        ch = 0x90;
                        break;

                    case 0x0639:
                        ch = 0x9A;
                        break;

                    case 0x063A:
                        ch = 0x9E;
                        break;

                    case 0x0640:
                        ch = 0x44;
                        break;

                    case 0x0641:
                        ch = 0xAB;
                        break;

                    case 0x0642:
                        ch = 0xAD;
                        break;

                    case 0x0643:
                        ch = 0xAF;
                        break;

                    case 0x0644:
                        ch = 0xB1;
                        break;

                    case 0x0645:
                        ch = 0xBB;
                        break;

                    case 0x0646:
                        ch = 0xBD;
                        break;

                    case 0x0647:
                        ch = 0xBF;
                        break;

                    case 0x0648:
                        ch = 0xCF;
                        break;

                    case 0x0649:
                        ch = 0xDA;
                        break;

                    case 0x064A:
                        ch = 0xDC;
                        break;

                    case 0x0651:
                        ch = 0x42;
                        break;

                    case 0x0660:
                        ch = 0xDF;
                        break;

                    case 0x0661:
                        ch = 0xEA;
                        break;

                    case 0x0662:
                        ch = 0xEB;
                        break;

                    case 0x0663:
                        ch = 0xED;
                        break;

                    case 0x0664:
                        ch = 0xEE;
                        break;

                    case 0x0665:
                        ch = 0xEF;
                        break;

                    case 0x0666:
                    case 0x0667:
                    case 0x0668:
                    case 0x0669:
                        ch -= 0x056B;
                        break;

                    case 0x066A:
                        ch = 0x6C;
                        break;

                    case 0x066B:
                        ch = 0x6B;
                        break;

                    case 0x066C:
                        ch = 0x4B;
                        break;

                    case 0x066D:
                        ch = 0x5C;
                        break;

                    case 0x200B:
                        ch = 0x45;
                        break;

                    case 0xFE7C:
                        ch = 0x42;
                        break;

                    case 0xFE7D:
                        ch = 0x43;
                        break;

                    case 0xFE80:
                    case 0xFE81:
                    case 0xFE82:
                    case 0xFE83:
                        ch -= 0xFE3A;
                        break;

                    case 0xFE84:
                        ch = 0x51;
                        break;

                    case 0xFE85:
                        ch = 0x52;
                        break;

                    case 0xFE86:
                        ch = 0x52;
                        break;

                    case 0xFE87:
                        ch = 0x56;
                        break;

                    case 0xFE88:
                        ch = 0x57;
                        break;

                    case 0xFE8B:
                        ch = 0x55;
                        break;

                    case 0xFE8C:
                    case 0xFE8D:
                    case 0xFE8E:
                    case 0xFE8F:
                        ch -= 0xFE37;
                        break;

                    case 0xFE90:
                        ch = 0x58;
                        break;

                    case 0xFE91:
                        ch = 0x59;
                        break;

                    case 0xFE92:
                        ch = 0x59;
                        break;

                    case 0xFE93:
                        ch = 0x62;
                        break;

                    case 0xFE94:
                        ch = 0x62;
                        break;

                    case 0xFE95:
                        ch = 0x63;
                        break;

                    case 0xFE96:
                        ch = 0x63;
                        break;

                    case 0xFE97:
                        ch = 0x64;
                        break;

                    case 0xFE98:
                        ch = 0x64;
                        break;

                    case 0xFE99:
                        ch = 0x65;
                        break;

                    case 0xFE9A:
                        ch = 0x65;
                        break;

                    case 0xFE9B:
                        ch = 0x66;
                        break;

                    case 0xFE9C:
                        ch = 0x66;
                        break;

                    case 0xFE9D:
                        ch = 0x67;
                        break;

                    case 0xFE9E:
                        ch = 0x67;
                        break;

                    case 0xFE9F:
                        ch = 0x68;
                        break;

                    case 0xFEA0:
                        ch = 0x68;
                        break;

                    case 0xFEA1:
                        ch = 0x69;
                        break;

                    case 0xFEA2:
                        ch = 0x69;
                        break;

                    case 0xFEA3:
                        ch = 0x70;
                        break;

                    case 0xFEA4:
                        ch = 0x70;
                        break;

                    case 0xFEA5:
                        ch = 0x71;
                        break;

                    case 0xFEA6:
                        ch = 0x71;
                        break;

                    case 0xFEA7:
                        ch = 0x72;
                        break;

                    case 0xFEA8:
                        ch = 0x72;
                        break;

                    case 0xFEA9:
                        ch = 0x73;
                        break;

                    case 0xFEAA:
                        ch = 0x73;
                        break;

                    case 0xFEAB:
                        ch = 0x74;
                        break;

                    case 0xFEAC:
                        ch = 0x74;
                        break;

                    case 0xFEAD:
                        ch = 0x75;
                        break;

                    case 0xFEAE:
                        ch = 0x75;
                        break;

                    case 0xFEAF:
                        ch = 0x76;
                        break;

                    case 0xFEB0:
                        ch = 0x76;
                        break;

                    case 0xFEB1:
                        ch = 0x77;
                        break;

                    case 0xFEB2:
                        ch = 0x77;
                        break;

                    case 0xFEB3:
                        ch = 0x78;
                        break;

                    case 0xFEB4:
                        ch = 0x78;
                        break;

                    case 0xFEB5:
                        ch = 0x80;
                        break;

                    case 0xFEB6:
                        ch = 0x80;
                        break;

                    case 0xFEB7:
                        ch = 0x8A;
                        break;

                    case 0xFEB8:
                        ch = 0x8A;
                        break;

                    case 0xFEB9:
                        ch = 0x8B;
                        break;

                    case 0xFEBA:
                        ch = 0x8B;
                        break;

                    case 0xFEBB:
                        ch = 0x8C;
                        break;

                    case 0xFEBC:
                        ch = 0x8C;
                        break;

                    case 0xFEBD:
                        ch = 0x8D;
                        break;

                    case 0xFEBE:
                        ch = 0x8D;
                        break;

                    case 0xFEBF:
                        ch = 0x8E;
                        break;

                    case 0xFEC0:
                        ch = 0x8E;
                        break;

                    case 0xFEC1:
                        ch = 0x8F;
                        break;

                    case 0xFEC2:
                        ch = 0x8F;
                        break;

                    case 0xFEC3:
                        ch = 0x8F;
                        break;

                    case 0xFEC4:
                        ch = 0x8F;
                        break;

                    case 0xFEC5:
                        ch = 0x90;
                        break;

                    case 0xFEC6:
                        ch = 0x90;
                        break;

                    case 0xFEC7:
                        ch = 0x90;
                        break;

                    case 0xFEC8:
                        ch = 0x90;
                        break;

                    case 0xFEC9:
                    case 0xFECA:
                    case 0xFECB:
                    case 0xFECC:
                    case 0xFECD:
                    case 0xFECE:
                    case 0xFECF:
                        ch -= 0xFE2F;
                        break;

                    case 0xFED0:
                        ch = 0xAA;
                        break;

                    case 0xFED1:
                        ch = 0xAB;
                        break;

                    case 0xFED2:
                        ch = 0xAB;
                        break;

                    case 0xFED3:
                        ch = 0xAC;
                        break;

                    case 0xFED4:
                        ch = 0xAC;
                        break;

                    case 0xFED5:
                        ch = 0xAD;
                        break;

                    case 0xFED6:
                        ch = 0xAD;
                        break;

                    case 0xFED7:
                        ch = 0xAE;
                        break;

                    case 0xFED8:
                        ch = 0xAE;
                        break;

                    case 0xFED9:
                        ch = 0xAF;
                        break;

                    case 0xFEDA:
                        ch = 0xAF;
                        break;

                    case 0xFEDB:
                        ch = 0xB0;
                        break;

                    case 0xFEDC:
                        ch = 0xB0;
                        break;

                    case 0xFEDD:
                        ch = 0xB1;
                        break;

                    case 0xFEDE:
                        ch = 0xB1;
                        break;

                    case 0xFEDF:
                        ch = 0xBA;
                        break;

                    case 0xFEE0:
                        ch = 0xBA;
                        break;

                    case 0xFEE1:
                        ch = 0xBB;
                        break;

                    case 0xFEE2:
                        ch = 0xBB;
                        break;

                    case 0xFEE3:
                        ch = 0xBC;
                        break;

                    case 0xFEE4:
                        ch = 0xBC;
                        break;

                    case 0xFEE5:
                        ch = 0xBD;
                        break;

                    case 0xFEE6:
                        ch = 0xBD;
                        break;

                    case 0xFEE7:
                        ch = 0xBE;
                        break;

                    case 0xFEE8:
                        ch = 0xBE;
                        break;

                    case 0xFEE9:
                        ch = 0xBF;
                        break;

                    case 0xFEEA:
                        ch = 0xBF;
                        break;

                    case 0xFEEB:
                        ch = 0xCB;
                        break;

                    case 0xFEEC:
                        ch = 0xCD;
                        break;

                    case 0xFEED:
                        ch = 0xCF;
                        break;

                    case 0xFEEE:
                        ch = 0xCF;
                        break;

                    case 0xFEEF:
                    case 0xFEF0:
                    case 0xFEF1:
                    case 0xFEF2:
                    case 0xFEF3:
                        ch -= 0xFE15;
                        break;

                    case 0xFEF4:
                        ch = 0xDE;
                        break;

                    case 0xFEF5:
                    case 0xFEF6:
                    case 0xFEF7:
                    case 0xFEF8:
                        ch -= 0xFE43;
                        break;

                    case 0xFEF9:
                        ch = 0xB8;
                        break;

                    case 0xFEFA:
                        ch = 0xB9;
                        break;

                    case 0xFEFB:
                        ch = 0xB8;
                        break;

                    case 0xFEFC:
                        ch = 0xB9;
                        break;

                    case 0xFF01:
                        ch = 0x5A;
                        break;

                    case 0xFF02:
                        ch = 0x7F;
                        break;

                    case 0xFF03:
                        ch = 0x7B;
                        break;

                    case 0xFF04:
                        ch = 0x5B;
                        break;

                    case 0xFF05:
                        ch = 0x6C;
                        break;

                    case 0xFF06:
                        ch = 0x50;
                        break;

                    case 0xFF07:
                        ch = 0x7D;
                        break;

                    case 0xFF08:
                        ch = 0x4D;
                        break;

                    case 0xFF09:
                        ch = 0x5D;
                        break;

                    case 0xFF0A:
                        ch = 0x5C;
                        break;

                    case 0xFF0B:
                        ch = 0x4E;
                        break;

                    case 0xFF0C:
                        ch = 0x6B;
                        break;

                    case 0xFF0D:
                        ch = 0x60;
                        break;

                    case 0xFF0E:
                        ch = 0x4B;
                        break;

                    case 0xFF0F:
                        ch = 0x61;
                        break;

                    case 0xFF10:
                    case 0xFF11:
                    case 0xFF12:
                    case 0xFF13:
                    case 0xFF14:
                    case 0xFF15:
                    case 0xFF16:
                    case 0xFF17:
                    case 0xFF18:
                    case 0xFF19:
                        ch -= 0xFE20;
                        break;

                    case 0xFF1A:
                        ch = 0x7A;
                        break;

                    case 0xFF1B:
                        ch = 0x5E;
                        break;

                    case 0xFF1C:
                        ch = 0x4C;
                        break;

                    case 0xFF1D:
                        ch = 0x7E;
                        break;

                    case 0xFF1E:
                        ch = 0x6E;
                        break;

                    case 0xFF1F:
                        ch = 0x6F;
                        break;

                    case 0xFF20:
                        ch = 0x7C;
                        break;

                    case 0xFF21:
                    case 0xFF22:
                    case 0xFF23:
                    case 0xFF24:
                    case 0xFF25:
                    case 0xFF26:
                    case 0xFF27:
                    case 0xFF28:
                    case 0xFF29:
                        ch -= 0xFE60;
                        break;

                    case 0xFF2A:
                    case 0xFF2B:
                    case 0xFF2C:
                    case 0xFF2D:
                    case 0xFF2E:
                    case 0xFF2F:
                    case 0xFF30:
                    case 0xFF31:
                    case 0xFF32:
                        ch -= 0xFE59;
                        break;

                    case 0xFF33:
                    case 0xFF34:
                    case 0xFF35:
                    case 0xFF36:
                    case 0xFF37:
                    case 0xFF38:
                    case 0xFF39:
                    case 0xFF3A:
                        ch -= 0xFE51;
                        break;

                    case 0xFF3F:
                        ch = 0x6D;
                        break;

                    case 0xFF41:
                    case 0xFF42:
                    case 0xFF43:
                    case 0xFF44:
                    case 0xFF45:
                    case 0xFF46:
                    case 0xFF47:
                    case 0xFF48:
                    case 0xFF49:
                        ch -= 0xFEC0;
                        break;

                    case 0xFF4A:
                    case 0xFF4B:
                    case 0xFF4C:
                    case 0xFF4D:
                    case 0xFF4E:
                    case 0xFF4F:
                    case 0xFF50:
                    case 0xFF51:
                    case 0xFF52:
                        ch -= 0xFEB9;
                        break;

                    case 0xFF53:
                    case 0xFF54:
                    case 0xFF55:
                    case 0xFF56:
                    case 0xFF57:
                    case 0xFF58:
                    case 0xFF59:
                    case 0xFF5A:
                        ch -= 0xFEB1;
                        break;

                    case 0xFF5C:
                        ch = 0x4F;
                        break;

                    default:
                        HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                        continue;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #24
0
		// Internal version of "GetBytes" which can handle a rolling
		// state between multiple calls to this method.
		static int InternalGetBytes (char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, EncoderFallback fallback, ref EncoderFallbackBuffer buffer, ref char leftOver, bool flush)
		{
			// Validate the parameters.
			if (chars == null)
				throw new ArgumentNullException ("chars");

			if (bytes == null)
				throw new ArgumentNullException ("bytes");

			if (charIndex < 0 || charIndex > chars.Length)
				throw new ArgumentOutOfRangeException ("charIndex");

			if (charCount < 0 || charCount > (chars.Length - charIndex))
				throw new ArgumentOutOfRangeException ("charCount");

			if (byteIndex < 0 || byteIndex > bytes.Length)
				throw new ArgumentOutOfRangeException ("byteIndex");

			if (charIndex == chars.Length) {
				if (flush && leftOver != '\0') {
					// FIXME: use EncoderFallback.
					//
					// By default it is empty, so I do nothing for now.
					leftOver = '\0';
				}

				return 0;
			}

			unsafe {
				fixed (char* cptr = chars) {
					if (bytes.Length == byteIndex)
						return InternalGetBytes (cptr + charIndex, charCount, null, 0, fallback, ref buffer, ref leftOver, flush);

					fixed (byte *bptr = bytes) {
						return InternalGetBytes (cptr + charIndex, charCount, bptr + byteIndex, bytes.Length - byteIndex, fallback, ref buffer, ref leftOver, flush);
					}
				}
			}
		}
コード例 #25
0
        unsafe int InternalGetBytes(char *chars, int charLength, int charIndex, int charCount, byte[] bytes, int byteIndex, ref EncoderFallbackBuffer buffer, ref char[] fallback_chars)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException("bytes");
            }

            if (charIndex < 0 || charIndex > charLength)
            {
                throw new ArgumentOutOfRangeException("charIndex");
            }

            if (charCount < 0 || charCount > (charLength - charIndex))
            {
                throw new ArgumentOutOfRangeException("charCount");
            }

            if (byteIndex < 0 || byteIndex > bytes.Length)
            {
                throw new ArgumentOutOfRangeException("byteIndex");
            }

            if ((bytes.Length - byteIndex) < charCount)
            {
                throw new ArgumentException("Insufficient space available.");
            }

            int  count = charCount;
            char ch;

            while (count-- > 0)
            {
                ch = chars [charIndex++];
                if (ch < (char)0x0100)
                {
                    bytes [byteIndex++] = (byte)ch;
                }
                else if (ch >= '\uFF01' && ch <= '\uFF5E')
                {
                    bytes [byteIndex++] = (byte)(ch - 0xFEE0);
                }
                else
                {
                    if (buffer == null)
                    {
                        buffer = EncoderFallback.CreateFallbackBuffer();
                    }

                    if (Char.IsSurrogate(ch) && count > 1 && Char.IsSurrogate(chars [charIndex]))
                    {
                        buffer.Fallback(ch, chars [charIndex], charIndex++ - 1);
                    }
                    else
                    {
                        buffer.Fallback(ch, charIndex - 1);
                    }

                    if (fallback_chars == null || fallback_chars.Length < buffer.Remaining)
                    {
                        fallback_chars = new char [buffer.Remaining];
                    }

                    for (int i = 0; i < fallback_chars.Length; i++)
                    {
                        fallback_chars [i] = buffer.GetNextChar();
                    }

                    byteIndex += GetBytes(fallback_chars, 0, fallback_chars.Length, bytes, byteIndex, ref buffer, ref fallback_chars);
                }
            }

            return(charCount);
        }
コード例 #26
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 26)
                {
                    switch (ch)
                    {
                    case 0x001B:
                    case 0x001D:
                    case 0x001E:
                    case 0x001F:
                    case 0x0020:
                    case 0x0021:
                    case 0x0022:
                    case 0x0023:
                    case 0x0024:
                    case 0x0025:
                    case 0x0026:
                    case 0x0027:
                    case 0x0028:
                    case 0x0029:
                    case 0x002A:
                    case 0x002B:
                    case 0x002C:
                    case 0x002D:
                    case 0x002E:
                    case 0x002F:
                    case 0x0030:
                    case 0x0031:
                    case 0x0032:
                    case 0x0033:
                    case 0x0034:
                    case 0x0035:
                    case 0x0036:
                    case 0x0037:
                    case 0x0038:
                    case 0x0039:
                    case 0x003A:
                    case 0x003B:
                    case 0x003C:
                    case 0x003D:
                    case 0x003E:
                    case 0x003F:
                    case 0x0040:
                    case 0x0041:
                    case 0x0042:
                    case 0x0043:
                    case 0x0044:
                    case 0x0045:
                    case 0x0046:
                    case 0x0047:
                    case 0x0048:
                    case 0x0049:
                    case 0x004A:
                    case 0x004B:
                    case 0x004C:
                    case 0x004D:
                    case 0x004E:
                    case 0x004F:
                    case 0x0050:
                    case 0x0051:
                    case 0x0052:
                    case 0x0053:
                    case 0x0054:
                    case 0x0055:
                    case 0x0056:
                    case 0x0057:
                    case 0x0058:
                    case 0x0059:
                    case 0x005A:
                    case 0x005B:
                    case 0x005C:
                    case 0x005D:
                    case 0x005E:
                    case 0x005F:
                    case 0x0060:
                    case 0x0061:
                    case 0x0062:
                    case 0x0063:
                    case 0x0064:
                    case 0x0065:
                    case 0x0066:
                    case 0x0067:
                    case 0x0068:
                    case 0x0069:
                    case 0x006A:
                    case 0x006B:
                    case 0x006C:
                    case 0x006D:
                    case 0x006E:
                    case 0x006F:
                    case 0x0070:
                    case 0x0071:
                    case 0x0072:
                    case 0x0073:
                    case 0x0074:
                    case 0x0075:
                    case 0x0076:
                    case 0x0077:
                    case 0x0078:
                    case 0x0079:
                    case 0x007A:
                    case 0x007B:
                    case 0x007C:
                    case 0x007D:
                    case 0x007E:
                    case 0x00A0:
                    case 0x00A3:
                    case 0x00A4:
                        break;

                    case 0x001A:
                        ch = 0x7F;
                        break;

                    case 0x001C:
                        ch = 0x1A;
                        break;

                    case 0x007F:
                        ch = 0x1C;
                        break;

                    case 0x00A2:
                        ch = 0xC0;
                        break;

                    case 0x00A6:
                        ch = 0xDB;
                        break;

                    case 0x00A7:
                        ch = 0x15;
                        break;

                    case 0x00AB:
                        ch = 0x97;
                        break;

                    case 0x00AC:
                        ch = 0xDC;
                        break;

                    case 0x00AD:
                        ch = 0xA1;
                        break;

                    case 0x00B0:
                        ch = 0x80;
                        break;

                    case 0x00B1:
                        ch = 0x93;
                        break;

                    case 0x00B6:
                        ch = 0x14;
                        break;

                    case 0x00B7:
                        ch = 0x81;
                        break;

                    case 0x00BB:
                        ch = 0x98;
                        break;

                    case 0x00BC:
                        ch = 0x95;
                        break;

                    case 0x00BD:
                        ch = 0x94;
                        break;

                    case 0x00D7:
                        ch = 0xDE;
                        break;

                    case 0x00F7:
                        ch = 0xDD;
                        break;

                    case 0x03B2:
                        ch = 0x90;
                        break;

                    case 0x03C6:
                        ch = 0x92;
                        break;

                    case 0x060C:
                        ch = 0xAC;
                        break;

                    case 0x061B:
                        ch = 0xBB;
                        break;

                    case 0x061F:
                        ch = 0xBF;
                        break;

                    case 0x0621:
                    case 0x0622:
                    case 0x0623:
                    case 0x0624:
                        ch -= 0x0560;
                        break;

                    case 0x0626:
                    case 0x0627:
                    case 0x0628:
                    case 0x0629:
                    case 0x062A:
                    case 0x062B:
                    case 0x062C:
                    case 0x062D:
                    case 0x062E:
                    case 0x062F:
                    case 0x0630:
                    case 0x0631:
                    case 0x0632:
                    case 0x0633:
                    case 0x0634:
                    case 0x0635:
                    case 0x0636:
                    case 0x0637:
                    case 0x0638:
                    case 0x0639:
                    case 0x063A:
                        ch -= 0x0560;
                        break;

                    case 0x0640:
                    case 0x0641:
                    case 0x0642:
                    case 0x0643:
                    case 0x0644:
                    case 0x0645:
                    case 0x0646:
                    case 0x0647:
                    case 0x0648:
                    case 0x0649:
                        ch -= 0x0560;
                        break;

                    case 0x064A:
                        ch = 0xFD;
                        break;

                    case 0x0651:
                        ch = 0xF1;
                        break;

                    case 0x0660:
                    case 0x0661:
                    case 0x0662:
                    case 0x0663:
                    case 0x0664:
                    case 0x0665:
                    case 0x0666:
                    case 0x0667:
                    case 0x0668:
                    case 0x0669:
                        ch -= 0x05B0;
                        break;

                    case 0x066A:
                        ch = 0x25;
                        break;

                    case 0x066B:
                        ch = 0x2C;
                        break;

                    case 0x066C:
                        ch = 0x2E;
                        break;

                    case 0x066D:
                        ch = 0x2A;
                        break;

                    case 0x200B:
                        ch = 0x9F;
                        break;

                    case 0x203C:
                        ch = 0x13;
                        break;

                    case 0x2190:
                        ch = 0x1B;
                        break;

                    case 0x2191:
                        ch = 0x18;
                        break;

                    case 0x2192:
                        ch = 0x1A;
                        break;

                    case 0x2193:
                        ch = 0x19;
                        break;

                    case 0x2194:
                        ch = 0x1D;
                        break;

                    case 0x2195:
                        ch = 0x12;
                        break;

                    case 0x21A8:
                        ch = 0x17;
                        break;

                    case 0x2219:
                        ch = 0x82;
                        break;

                    case 0x221A:
                        ch = 0x83;
                        break;

                    case 0x221E:
                        ch = 0x91;
                        break;

                    case 0x221F:
                        ch = 0x1C;
                        break;

                    case 0x2248:
                        ch = 0x96;
                        break;

                    case 0x2302:
                        ch = 0x7F;
                        break;

                    case 0x2500:
                        ch = 0x85;
                        break;

                    case 0x2502:
                        ch = 0x86;
                        break;

                    case 0x250C:
                        ch = 0x8D;
                        break;

                    case 0x2510:
                        ch = 0x8C;
                        break;

                    case 0x2514:
                        ch = 0x8E;
                        break;

                    case 0x2518:
                        ch = 0x8F;
                        break;

                    case 0x251C:
                        ch = 0x8A;
                        break;

                    case 0x2524:
                        ch = 0x88;
                        break;

                    case 0x252C:
                        ch = 0x89;
                        break;

                    case 0x2534:
                        ch = 0x8B;
                        break;

                    case 0x253C:
                        ch = 0x87;
                        break;

                    case 0x2550:
                        ch = 0x05;
                        break;

                    case 0x2551:
                        ch = 0x06;
                        break;

                    case 0x2554:
                        ch = 0x0D;
                        break;

                    case 0x2557:
                        ch = 0x0C;
                        break;

                    case 0x255A:
                        ch = 0x0E;
                        break;

                    case 0x255D:
                        ch = 0x0F;
                        break;

                    case 0x2560:
                        ch = 0x0A;
                        break;

                    case 0x2563:
                        ch = 0x08;
                        break;

                    case 0x2566:
                        ch = 0x09;
                        break;

                    case 0x2569:
                        ch = 0x0B;
                        break;

                    case 0x256C:
                        ch = 0x07;
                        break;

                    case 0x2592:
                        ch = 0x84;
                        break;

                    case 0x25A0:
                        ch = 0xFE;
                        break;

                    case 0x25AC:
                        ch = 0x16;
                        break;

                    case 0x25B2:
                        ch = 0x1E;
                        break;

                    case 0x25BA:
                        ch = 0x10;
                        break;

                    case 0x25BC:
                        ch = 0x1F;
                        break;

                    case 0x25C4:
                        ch = 0x11;
                        break;

                    case 0x263A:
                        ch = 0x01;
                        break;

                    case 0x263C:
                        ch = 0x04;
                        break;

                    case 0x266A:
                        ch = 0x02;
                        break;

                    case 0x266C:
                        ch = 0x03;
                        break;

                    case 0xFE7C:
                        ch = 0xF1;
                        break;

                    case 0xFE7D:
                        ch = 0xF0;
                        break;

                    case 0xFE80:
                        ch = 0xC1;
                        break;

                    case 0xFE81:
                        ch = 0xC2;
                        break;

                    case 0xFE82:
                        ch = 0xA2;
                        break;

                    case 0xFE83:
                        ch = 0xC3;
                        break;

                    case 0xFE84:
                        ch = 0xA5;
                        break;

                    case 0xFE85:
                        ch = 0xC4;
                        break;

                    case 0xFE86:
                        ch = 0xC4;
                        break;

                    case 0xFE8B:
                        ch = 0xC6;
                        break;

                    case 0xFE8C:
                        ch = 0xC6;
                        break;

                    case 0xFE8D:
                        ch = 0xC7;
                        break;

                    case 0xFE8E:
                        ch = 0xA8;
                        break;

                    case 0xFE8F:
                        ch = 0xA9;
                        break;

                    case 0xFE90:
                        ch = 0xA9;
                        break;

                    case 0xFE91:
                        ch = 0xC8;
                        break;

                    case 0xFE92:
                        ch = 0xC8;
                        break;

                    case 0xFE93:
                        ch = 0xC9;
                        break;

                    case 0xFE94:
                        ch = 0xC9;
                        break;

                    case 0xFE95:
                        ch = 0xAA;
                        break;

                    case 0xFE96:
                        ch = 0xAA;
                        break;

                    case 0xFE97:
                        ch = 0xCA;
                        break;

                    case 0xFE98:
                        ch = 0xCA;
                        break;

                    case 0xFE99:
                        ch = 0xAB;
                        break;

                    case 0xFE9A:
                        ch = 0xAB;
                        break;

                    case 0xFE9B:
                        ch = 0xCB;
                        break;

                    case 0xFE9C:
                        ch = 0xCB;
                        break;

                    case 0xFE9D:
                        ch = 0xAD;
                        break;

                    case 0xFE9E:
                        ch = 0xAD;
                        break;

                    case 0xFE9F:
                        ch = 0xCC;
                        break;

                    case 0xFEA0:
                        ch = 0xCC;
                        break;

                    case 0xFEA1:
                        ch = 0xAE;
                        break;

                    case 0xFEA2:
                        ch = 0xAE;
                        break;

                    case 0xFEA3:
                        ch = 0xCD;
                        break;

                    case 0xFEA4:
                        ch = 0xCD;
                        break;

                    case 0xFEA5:
                        ch = 0xAF;
                        break;

                    case 0xFEA6:
                        ch = 0xAF;
                        break;

                    case 0xFEA7:
                        ch = 0xCE;
                        break;

                    case 0xFEA8:
                        ch = 0xCE;
                        break;

                    case 0xFEA9:
                        ch = 0xCF;
                        break;

                    case 0xFEAA:
                        ch = 0xCF;
                        break;

                    case 0xFEAB:
                        ch = 0xD0;
                        break;

                    case 0xFEAC:
                        ch = 0xD0;
                        break;

                    case 0xFEAD:
                        ch = 0xD1;
                        break;

                    case 0xFEAE:
                        ch = 0xD1;
                        break;

                    case 0xFEAF:
                        ch = 0xD2;
                        break;

                    case 0xFEB0:
                        ch = 0xD2;
                        break;

                    case 0xFEB1:
                        ch = 0xBC;
                        break;

                    case 0xFEB2:
                        ch = 0xBC;
                        break;

                    case 0xFEB3:
                        ch = 0xD3;
                        break;

                    case 0xFEB4:
                        ch = 0xD3;
                        break;

                    case 0xFEB5:
                        ch = 0xBD;
                        break;

                    case 0xFEB6:
                        ch = 0xBD;
                        break;

                    case 0xFEB7:
                        ch = 0xD4;
                        break;

                    case 0xFEB8:
                        ch = 0xD4;
                        break;

                    case 0xFEB9:
                        ch = 0xBE;
                        break;

                    case 0xFEBA:
                        ch = 0xBE;
                        break;

                    case 0xFEBB:
                        ch = 0xD5;
                        break;

                    case 0xFEBC:
                        ch = 0xD5;
                        break;

                    case 0xFEBD:
                        ch = 0xEB;
                        break;

                    case 0xFEBE:
                        ch = 0xEB;
                        break;

                    case 0xFEBF:
                        ch = 0xD6;
                        break;

                    case 0xFEC0:
                        ch = 0xD6;
                        break;

                    case 0xFEC1:
                        ch = 0xD7;
                        break;

                    case 0xFEC2:
                        ch = 0xD7;
                        break;

                    case 0xFEC3:
                        ch = 0xD7;
                        break;

                    case 0xFEC4:
                        ch = 0xD7;
                        break;

                    case 0xFEC5:
                        ch = 0xD8;
                        break;

                    case 0xFEC6:
                        ch = 0xD8;
                        break;

                    case 0xFEC7:
                        ch = 0xD8;
                        break;

                    case 0xFEC8:
                        ch = 0xD8;
                        break;

                    case 0xFEC9:
                        ch = 0xDF;
                        break;

                    case 0xFECA:
                        ch = 0xC5;
                        break;

                    case 0xFECB:
                        ch = 0xD9;
                        break;

                    case 0xFECC:
                        ch = 0xEC;
                        break;

                    case 0xFECD:
                        ch = 0xEE;
                        break;

                    case 0xFECE:
                        ch = 0xED;
                        break;

                    case 0xFECF:
                        ch = 0xDA;
                        break;

                    case 0xFED0:
                        ch = 0xF7;
                        break;

                    case 0xFED1:
                        ch = 0xBA;
                        break;

                    case 0xFED2:
                        ch = 0xBA;
                        break;

                    case 0xFED3:
                        ch = 0xE1;
                        break;

                    case 0xFED4:
                        ch = 0xE1;
                        break;

                    case 0xFED5:
                        ch = 0xF8;
                        break;

                    case 0xFED6:
                        ch = 0xF8;
                        break;

                    case 0xFED7:
                        ch = 0xE2;
                        break;

                    case 0xFED8:
                        ch = 0xE2;
                        break;

                    case 0xFED9:
                        ch = 0xFC;
                        break;

                    case 0xFEDA:
                        ch = 0xFC;
                        break;

                    case 0xFEDB:
                        ch = 0xE3;
                        break;

                    case 0xFEDC:
                        ch = 0xE3;
                        break;

                    case 0xFEDD:
                        ch = 0xFB;
                        break;

                    case 0xFEDE:
                        ch = 0xFB;
                        break;

                    case 0xFEDF:
                        ch = 0xE4;
                        break;

                    case 0xFEE0:
                        ch = 0xE4;
                        break;

                    case 0xFEE1:
                        ch = 0xEF;
                        break;

                    case 0xFEE2:
                        ch = 0xEF;
                        break;

                    case 0xFEE3:
                        ch = 0xE5;
                        break;

                    case 0xFEE4:
                        ch = 0xE5;
                        break;

                    case 0xFEE5:
                        ch = 0xF2;
                        break;

                    case 0xFEE6:
                        ch = 0xF2;
                        break;

                    case 0xFEE7:
                        ch = 0xE6;
                        break;

                    case 0xFEE8:
                        ch = 0xE6;
                        break;

                    case 0xFEE9:
                        ch = 0xF3;
                        break;

                    case 0xFEEA:
                        ch = 0xF3;
                        break;

                    case 0xFEEB:
                        ch = 0xE7;
                        break;

                    case 0xFEEC:
                        ch = 0xF4;
                        break;

                    case 0xFEED:
                        ch = 0xE8;
                        break;

                    case 0xFEEE:
                        ch = 0xE8;
                        break;

                    case 0xFEEF:
                        ch = 0xE9;
                        break;

                    case 0xFEF0:
                        ch = 0xF5;
                        break;

                    case 0xFEF1:
                        ch = 0xFD;
                        break;

                    case 0xFEF2:
                        ch = 0xF6;
                        break;

                    case 0xFEF3:
                        ch = 0xEA;
                        break;

                    case 0xFEF4:
                        ch = 0xEA;
                        break;

                    case 0xFEF5:
                        ch = 0xF9;
                        break;

                    case 0xFEF6:
                        ch = 0xFA;
                        break;

                    case 0xFEF7:
                        ch = 0x99;
                        break;

                    case 0xFEF8:
                        ch = 0x9A;
                        break;

                    case 0xFEFB:
                        ch = 0x9D;
                        break;

                    case 0xFEFC:
                        ch = 0x9E;
                        break;

                    case 0xFFE8:
                        ch = 0x86;
                        break;

                    case 0xFFE9:
                        ch = 0x1B;
                        break;

                    case 0xFFEA:
                        ch = 0x18;
                        break;

                    case 0xFFEB:
                        ch = 0x1A;
                        break;

                    case 0xFFEC:
                        ch = 0x19;
                        break;

                    case 0xFFED:
                        ch = 0xFE;
                        break;

                    default:
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                        break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #27
0
        int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, ref EncoderFallbackBuffer buffer, ref char[] fallback_chars)
        {
            if (chars == null)
            {
                throw new ArgumentNullException("chars");
            }

            unsafe
            {
                fixed(char *cptr = chars)
                {
                    return(InternalGetBytes(cptr, chars.Length, charIndex, charCount, bytes, byteIndex, ref buffer, ref fallback_chars));
                }
            }
        }
コード例 #28
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 4)
                {
                    switch (ch)
                    {
                    case 0x000B:
                    case 0x000C:
                    case 0x000D:
                    case 0x000E:
                    case 0x000F:
                    case 0x0010:
                    case 0x0011:
                    case 0x0012:
                    case 0x0013:
                    case 0x0018:
                    case 0x0019:
                    case 0x001C:
                    case 0x001D:
                    case 0x001E:
                    case 0x001F:
                    case 0x00B6:
                        break;

                    case 0x0004:
                        ch = 0x37;
                        break;

                    case 0x0005:
                        ch = 0x2D;
                        break;

                    case 0x0006:
                        ch = 0x2E;
                        break;

                    case 0x0007:
                        ch = 0x2F;
                        break;

                    case 0x0008:
                        ch = 0x16;
                        break;

                    case 0x0009:
                        ch = 0x05;
                        break;

                    case 0x000A:
                        ch = 0x25;
                        break;

                    case 0x0014:
                        ch = 0x3C;
                        break;

                    case 0x0015:
                        ch = 0x3D;
                        break;

                    case 0x0016:
                        ch = 0x32;
                        break;

                    case 0x0017:
                        ch = 0x26;
                        break;

                    case 0x001A:
                        ch = 0x3F;
                        break;

                    case 0x001B:
                        ch = 0x27;
                        break;

                    case 0x0020:
                        ch = 0x40;
                        break;

                    case 0x0021:
                        ch = 0x5A;
                        break;

                    case 0x0022:
                        ch = 0x7F;
                        break;

                    case 0x0023:
                        ch = 0x7B;
                        break;

                    case 0x0024:
                        ch = 0x5B;
                        break;

                    case 0x0025:
                        ch = 0x6C;
                        break;

                    case 0x0026:
                        ch = 0x50;
                        break;

                    case 0x0027:
                        ch = 0x7D;
                        break;

                    case 0x0028:
                        ch = 0x4D;
                        break;

                    case 0x0029:
                        ch = 0x5D;
                        break;

                    case 0x002A:
                        ch = 0x5C;
                        break;

                    case 0x002B:
                        ch = 0x4E;
                        break;

                    case 0x002C:
                        ch = 0x6B;
                        break;

                    case 0x002D:
                        ch = 0x60;
                        break;

                    case 0x002E:
                        ch = 0x4B;
                        break;

                    case 0x002F:
                        ch = 0x61;
                        break;

                    case 0x0030:
                    case 0x0031:
                    case 0x0032:
                    case 0x0033:
                    case 0x0034:
                    case 0x0035:
                    case 0x0036:
                    case 0x0037:
                    case 0x0038:
                    case 0x0039:
                        ch += 0x00C0;
                        break;

                    case 0x003A:
                        ch = 0x7A;
                        break;

                    case 0x003B:
                        ch = 0x5E;
                        break;

                    case 0x003C:
                        ch = 0x4C;
                        break;

                    case 0x003D:
                        ch = 0x7E;
                        break;

                    case 0x003E:
                        ch = 0x6E;
                        break;

                    case 0x003F:
                        ch = 0x6F;
                        break;

                    case 0x0040:
                        ch = 0x7C;
                        break;

                    case 0x0041:
                    case 0x0042:
                    case 0x0043:
                    case 0x0044:
                    case 0x0045:
                    case 0x0046:
                    case 0x0047:
                    case 0x0048:
                    case 0x0049:
                        ch += 0x0080;
                        break;

                    case 0x004A:
                    case 0x004B:
                    case 0x004C:
                    case 0x004D:
                    case 0x004E:
                    case 0x004F:
                    case 0x0050:
                    case 0x0051:
                    case 0x0052:
                        ch += 0x0087;
                        break;

                    case 0x0053:
                    case 0x0054:
                    case 0x0055:
                    case 0x0056:
                    case 0x0057:
                    case 0x0058:
                    case 0x0059:
                    case 0x005A:
                        ch += 0x008F;
                        break;

                    case 0x005B:
                        ch = 0xBA;
                        break;

                    case 0x005C:
                        ch = 0xE0;
                        break;

                    case 0x005D:
                        ch = 0xBB;
                        break;

                    case 0x005E:
                        ch = 0xB0;
                        break;

                    case 0x005F:
                        ch = 0x6D;
                        break;

                    case 0x0060:
                        ch = 0x79;
                        break;

                    case 0x0061:
                    case 0x0062:
                    case 0x0063:
                    case 0x0064:
                    case 0x0065:
                    case 0x0066:
                    case 0x0067:
                    case 0x0068:
                    case 0x0069:
                        ch += 0x0020;
                        break;

                    case 0x006A:
                    case 0x006B:
                    case 0x006C:
                    case 0x006D:
                    case 0x006E:
                    case 0x006F:
                    case 0x0070:
                    case 0x0071:
                    case 0x0072:
                        ch += 0x0027;
                        break;

                    case 0x0073:
                    case 0x0074:
                    case 0x0075:
                    case 0x0076:
                    case 0x0077:
                    case 0x0078:
                    case 0x0079:
                    case 0x007A:
                        ch += 0x002F;
                        break;

                    case 0x007B:
                        ch = 0xC0;
                        break;

                    case 0x007C:
                        ch = 0x4F;
                        break;

                    case 0x007D:
                        ch = 0xD0;
                        break;

                    case 0x007E:
                        ch = 0xA1;
                        break;

                    case 0x007F:
                        ch = 0x07;
                        break;

                    case 0x0080:
                    case 0x0081:
                    case 0x0082:
                    case 0x0083:
                    case 0x0084:
                        ch -= 0x0060;
                        break;

                    case 0x0085:
                        ch = 0x15;
                        break;

                    case 0x0086:
                        ch = 0x06;
                        break;

                    case 0x0087:
                        ch = 0x17;
                        break;

                    case 0x0088:
                    case 0x0089:
                    case 0x008A:
                    case 0x008B:
                    case 0x008C:
                        ch -= 0x0060;
                        break;

                    case 0x008D:
                        ch = 0x09;
                        break;

                    case 0x008E:
                        ch = 0x0A;
                        break;

                    case 0x008F:
                        ch = 0x1B;
                        break;

                    case 0x0090:
                        ch = 0x30;
                        break;

                    case 0x0091:
                        ch = 0x31;
                        break;

                    case 0x0092:
                        ch = 0x1A;
                        break;

                    case 0x0093:
                    case 0x0094:
                    case 0x0095:
                    case 0x0096:
                        ch -= 0x0060;
                        break;

                    case 0x0097:
                        ch = 0x08;
                        break;

                    case 0x0098:
                    case 0x0099:
                    case 0x009A:
                    case 0x009B:
                        ch -= 0x0060;
                        break;

                    case 0x009C:
                        ch = 0x04;
                        break;

                    case 0x009D:
                        ch = 0x14;
                        break;

                    case 0x009E:
                        ch = 0x3E;
                        break;

                    case 0x009F:
                        ch = 0xFF;
                        break;

                    case 0x00A0:
                        ch = 0x41;
                        break;

                    case 0x00A1:
                        ch = 0xAA;
                        break;

                    case 0x00A2:
                        ch = 0x4A;
                        break;

                    case 0x00A3:
                        ch = 0xB1;
                        break;

                    case 0x00A4:
                        ch = 0x9F;
                        break;

                    case 0x00A5:
                        ch = 0xB2;
                        break;

                    case 0x00A6:
                        ch = 0x6A;
                        break;

                    case 0x00A7:
                        ch = 0xB5;
                        break;

                    case 0x00A8:
                        ch = 0xBD;
                        break;

                    case 0x00A9:
                        ch = 0xB4;
                        break;

                    case 0x00AA:
                        ch = 0x9A;
                        break;

                    case 0x00AB:
                        ch = 0x8A;
                        break;

                    case 0x00AC:
                        ch = 0x5F;
                        break;

                    case 0x00AD:
                        ch = 0xCA;
                        break;

                    case 0x00AE:
                        ch = 0xAF;
                        break;

                    case 0x00AF:
                        ch = 0xBC;
                        break;

                    case 0x00B0:
                        ch = 0x90;
                        break;

                    case 0x00B1:
                        ch = 0x8F;
                        break;

                    case 0x00B2:
                        ch = 0xEA;
                        break;

                    case 0x00B3:
                        ch = 0xFA;
                        break;

                    case 0x00B4:
                        ch = 0xBE;
                        break;

                    case 0x00B5:
                        ch = 0xA0;
                        break;

                    case 0x00B7:
                        ch = 0xB3;
                        break;

                    case 0x00B8:
                        ch = 0x9D;
                        break;

                    case 0x00B9:
                        ch = 0xDA;
                        break;

                    case 0x00BA:
                        ch = 0x9B;
                        break;

                    case 0x00BB:
                        ch = 0x8B;
                        break;

                    case 0x00BC:
                        ch = 0xB7;
                        break;

                    case 0x00BD:
                        ch = 0xB8;
                        break;

                    case 0x00BE:
                        ch = 0xB9;
                        break;

                    case 0x00BF:
                        ch = 0xAB;
                        break;

                    case 0x00C0:
                        ch = 0x64;
                        break;

                    case 0x00C1:
                        ch = 0x65;
                        break;

                    case 0x00C2:
                        ch = 0x62;
                        break;

                    case 0x00C3:
                        ch = 0x66;
                        break;

                    case 0x00C4:
                        ch = 0x63;
                        break;

                    case 0x00C5:
                        ch = 0x67;
                        break;

                    case 0x00C6:
                        ch = 0x9E;
                        break;

                    case 0x00C7:
                        ch = 0x68;
                        break;

                    case 0x00C8:
                        ch = 0x74;
                        break;

                    case 0x00C9:
                        ch = 0x71;
                        break;

                    case 0x00CA:
                        ch = 0x72;
                        break;

                    case 0x00CB:
                        ch = 0x73;
                        break;

                    case 0x00CC:
                        ch = 0x78;
                        break;

                    case 0x00CD:
                        ch = 0x75;
                        break;

                    case 0x00CE:
                        ch = 0x76;
                        break;

                    case 0x00CF:
                        ch = 0x77;
                        break;

                    case 0x00D0:
                        ch = 0xAC;
                        break;

                    case 0x00D1:
                        ch = 0x69;
                        break;

                    case 0x00D2:
                        ch = 0xED;
                        break;

                    case 0x00D3:
                        ch = 0xEE;
                        break;

                    case 0x00D4:
                        ch = 0xEB;
                        break;

                    case 0x00D5:
                        ch = 0xEF;
                        break;

                    case 0x00D6:
                        ch = 0xEC;
                        break;

                    case 0x00D7:
                        ch = 0xBF;
                        break;

                    case 0x00D8:
                        ch = 0x80;
                        break;

                    case 0x00D9:
                        ch = 0xFD;
                        break;

                    case 0x00DA:
                        ch = 0xFE;
                        break;

                    case 0x00DB:
                        ch = 0xFB;
                        break;

                    case 0x00DC:
                        ch = 0xFC;
                        break;

                    case 0x00DD:
                        ch = 0xAD;
                        break;

                    case 0x00DE:
                        ch = 0xAE;
                        break;

                    case 0x00DF:
                        ch = 0x59;
                        break;

                    case 0x00E0:
                        ch = 0x44;
                        break;

                    case 0x00E1:
                        ch = 0x45;
                        break;

                    case 0x00E2:
                        ch = 0x42;
                        break;

                    case 0x00E3:
                        ch = 0x46;
                        break;

                    case 0x00E4:
                        ch = 0x43;
                        break;

                    case 0x00E5:
                        ch = 0x47;
                        break;

                    case 0x00E6:
                        ch = 0x9C;
                        break;

                    case 0x00E7:
                        ch = 0x48;
                        break;

                    case 0x00E8:
                        ch = 0x54;
                        break;

                    case 0x00E9:
                        ch = 0x51;
                        break;

                    case 0x00EA:
                        ch = 0x52;
                        break;

                    case 0x00EB:
                        ch = 0x53;
                        break;

                    case 0x00EC:
                        ch = 0x58;
                        break;

                    case 0x00ED:
                        ch = 0x55;
                        break;

                    case 0x00EE:
                        ch = 0x56;
                        break;

                    case 0x00EF:
                        ch = 0x57;
                        break;

                    case 0x00F0:
                        ch = 0x8C;
                        break;

                    case 0x00F1:
                        ch = 0x49;
                        break;

                    case 0x00F2:
                        ch = 0xCD;
                        break;

                    case 0x00F3:
                        ch = 0xCE;
                        break;

                    case 0x00F4:
                        ch = 0xCB;
                        break;

                    case 0x00F5:
                        ch = 0xCF;
                        break;

                    case 0x00F6:
                        ch = 0xCC;
                        break;

                    case 0x00F7:
                        ch = 0xE1;
                        break;

                    case 0x00F8:
                        ch = 0x70;
                        break;

                    case 0x00F9:
                        ch = 0xDD;
                        break;

                    case 0x00FA:
                        ch = 0xDE;
                        break;

                    case 0x00FB:
                        ch = 0xDB;
                        break;

                    case 0x00FC:
                        ch = 0xDC;
                        break;

                    case 0x00FD:
                        ch = 0x8D;
                        break;

                    case 0x00FE:
                        ch = 0x8E;
                        break;

                    case 0x00FF:
                        ch = 0xDF;
                        break;

                    case 0x0110:
                        ch = 0xAC;
                        break;

                    case 0x203E:
                        ch = 0xBC;
                        break;

                    case 0xFF01:
                        ch = 0x5A;
                        break;

                    case 0xFF02:
                        ch = 0x7F;
                        break;

                    case 0xFF03:
                        ch = 0x7B;
                        break;

                    case 0xFF04:
                        ch = 0x5B;
                        break;

                    case 0xFF05:
                        ch = 0x6C;
                        break;

                    case 0xFF06:
                        ch = 0x50;
                        break;

                    case 0xFF07:
                        ch = 0x7D;
                        break;

                    case 0xFF08:
                        ch = 0x4D;
                        break;

                    case 0xFF09:
                        ch = 0x5D;
                        break;

                    case 0xFF0A:
                        ch = 0x5C;
                        break;

                    case 0xFF0B:
                        ch = 0x4E;
                        break;

                    case 0xFF0C:
                        ch = 0x6B;
                        break;

                    case 0xFF0D:
                        ch = 0x60;
                        break;

                    case 0xFF0E:
                        ch = 0x4B;
                        break;

                    case 0xFF0F:
                        ch = 0x61;
                        break;

                    case 0xFF10:
                    case 0xFF11:
                    case 0xFF12:
                    case 0xFF13:
                    case 0xFF14:
                    case 0xFF15:
                    case 0xFF16:
                    case 0xFF17:
                    case 0xFF18:
                    case 0xFF19:
                        ch -= 0xFE20;
                        break;

                    case 0xFF1A:
                        ch = 0x7A;
                        break;

                    case 0xFF1B:
                        ch = 0x5E;
                        break;

                    case 0xFF1C:
                        ch = 0x4C;
                        break;

                    case 0xFF1D:
                        ch = 0x7E;
                        break;

                    case 0xFF1E:
                        ch = 0x6E;
                        break;

                    case 0xFF1F:
                        ch = 0x6F;
                        break;

                    case 0xFF20:
                        ch = 0x7C;
                        break;

                    case 0xFF21:
                    case 0xFF22:
                    case 0xFF23:
                    case 0xFF24:
                    case 0xFF25:
                    case 0xFF26:
                    case 0xFF27:
                    case 0xFF28:
                    case 0xFF29:
                        ch -= 0xFE60;
                        break;

                    case 0xFF2A:
                    case 0xFF2B:
                    case 0xFF2C:
                    case 0xFF2D:
                    case 0xFF2E:
                    case 0xFF2F:
                    case 0xFF30:
                    case 0xFF31:
                    case 0xFF32:
                        ch -= 0xFE59;
                        break;

                    case 0xFF33:
                    case 0xFF34:
                    case 0xFF35:
                    case 0xFF36:
                    case 0xFF37:
                    case 0xFF38:
                    case 0xFF39:
                    case 0xFF3A:
                        ch -= 0xFE51;
                        break;

                    case 0xFF3B:
                        ch = 0xBA;
                        break;

                    case 0xFF3C:
                        ch = 0xE0;
                        break;

                    case 0xFF3D:
                        ch = 0xBB;
                        break;

                    case 0xFF3E:
                        ch = 0xB0;
                        break;

                    case 0xFF3F:
                        ch = 0x6D;
                        break;

                    case 0xFF40:
                        ch = 0x79;
                        break;

                    case 0xFF41:
                    case 0xFF42:
                    case 0xFF43:
                    case 0xFF44:
                    case 0xFF45:
                    case 0xFF46:
                    case 0xFF47:
                    case 0xFF48:
                    case 0xFF49:
                        ch -= 0xFEC0;
                        break;

                    case 0xFF4A:
                    case 0xFF4B:
                    case 0xFF4C:
                    case 0xFF4D:
                    case 0xFF4E:
                    case 0xFF4F:
                    case 0xFF50:
                    case 0xFF51:
                    case 0xFF52:
                        ch -= 0xFEB9;
                        break;

                    case 0xFF53:
                    case 0xFF54:
                    case 0xFF55:
                    case 0xFF56:
                    case 0xFF57:
                    case 0xFF58:
                    case 0xFF59:
                    case 0xFF5A:
                        ch -= 0xFEB1;
                        break;

                    case 0xFF5B:
                        ch = 0xC0;
                        break;

                    case 0xFF5C:
                        ch = 0x4F;
                        break;

                    case 0xFF5D:
                        ch = 0xD0;
                        break;

                    case 0xFF5E:
                        ch = 0xA1;
                        break;

                    default:
                        HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                        continue;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #29
0
		unsafe int InternalGetBytes (char *chars, int charLength, int charIndex, int charCount, byte[] bytes, int byteIndex, ref EncoderFallbackBuffer buffer, ref char[] fallback_chars)
		{
			if (bytes == null)
				throw new ArgumentNullException ("bytes");

			if (charIndex < 0 || charIndex > charLength)
				throw new ArgumentOutOfRangeException ("charIndex");

			if (charCount < 0 || charCount > (charLength - charIndex))
				throw new ArgumentOutOfRangeException ("charCount");

			if (byteIndex < 0 || byteIndex > bytes.Length)
				throw new ArgumentOutOfRangeException ("byteIndex");

			if ((bytes.Length - byteIndex) < charCount)
				throw new ArgumentException ("Insufficient space available.");

			int count = charCount;
			char ch;

			while (count-- > 0) {
				ch = chars [charIndex++];
				if (ch < (char) 0x80) {
					bytes [byteIndex++] = (byte) ch;
				} else {
					if (buffer == null)
						buffer = EncoderFallback.CreateFallbackBuffer ();

					if (Char.IsSurrogate (ch) && count > 1 && Char.IsSurrogate (chars [charIndex]))
						buffer.Fallback (ch, chars [charIndex], charIndex++ - 1);
					else
						buffer.Fallback (ch, charIndex - 1);

					if (fallback_chars == null || fallback_chars.Length < buffer.Remaining)
						fallback_chars = new char [buffer.Remaining];

					for (int i = 0; i < fallback_chars.Length; i++)
						fallback_chars[i] = buffer.GetNextChar ();

					byteIndex += GetBytes (fallback_chars, 0, fallback_chars.Length, bytes, byteIndex, ref buffer, ref fallback_chars);
				}
			}
			return charCount;
		}
コード例 #30
0
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetBytesImpl(char *chars, int charCount, byte *bytes, int byteCount)
        {
            EncoderFallbackBuffer buffer = null;
            int charIndex = 0;
            int byteIndex = 0;

            // Convert the characters into their byte form.
            byte[] extraToJis = JISConvert.Convert.ExtraToJis;
            byte[] greekToJis = JISConvert.Convert.GreekToJis;
            byte[] cjkToJis = JISConvert.Convert.CjkToJis;
            int    byteLength = byteCount;
            int    posn = byteIndex;
            int    end = charCount;
            int    ch, value;

            for (int i = charIndex; i < end; i++, charCount--)
            {
                ch = chars [i];
                if (posn >= byteLength)
                {
                    throw new ArgumentException("Insufficient space available.", "bytes");
                }

                if (ch < 0x0080)
                {
                    // Character maps to itself.
                    bytes [posn++] = (byte)ch;
                    continue;
                }
                else if (ch < 0x0100)
                {
                    // Check for special Latin 1 characters that
                    // can be mapped to double-byte code points.
                    if (ch == 0x00A2 || ch == 0x00A3 || ch == 0x00A7 ||
                        ch == 0x00A8 || ch == 0x00AC || ch == 0x00B0 ||
                        ch == 0x00B1 || ch == 0x00B4 || ch == 0x00B6 ||
                        ch == 0x00D7 || ch == 0x00F7)
                    {
                        if ((posn + 1) >= byteLength)
                        {
                            throw new ArgumentException("Insufficient space available.", "bytes");
                        }

                        switch (ch)
                        {
                        case 0x00A2:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x91;
                            break;

                        case 0x00A3:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x92;
                            break;

                        case 0x00A7:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x98;
                            break;

                        case 0x00A8:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x4E;
                            break;

                        case 0x00AC:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0xCA;
                            break;

                        case 0x00B0:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x8B;
                            break;

                        case 0x00B1:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x7D;
                            break;

                        case 0x00B4:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x4C;
                            break;

                        case 0x00B6:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0xF7;
                            break;

                        case 0x00D7:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x7E;
                            break;

                        case 0x00F7:
                            bytes [posn++] = (byte)0x81;
                            bytes [posn++] = (byte)0x80;
                            break;
                        }
                    }
                    else if (ch == 0x00A5)
                    {
                        // Yen sign.
                        bytes [posn++] = (byte)0x5C;
                    }
                    else
                    {
                        HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref posn, ref byteCount, null);
                    }
                    continue;
                }
                else if (ch >= 0x0391 && ch <= 0x0451)
                {
                    // Greek subset characters.
                    value = (ch - 0x0391) * 2;
                    value = ((int)(greekToJis [value])) | (((int)(greekToJis [value + 1])) << 8);
                }
                else if (ch >= 0x2010 && ch <= 0x9FA5)
                {
                    // This range contains the bulk of the CJK set.
                    value = (ch - 0x2010) * 2;
                    value = ((int)(cjkToJis [value])) | (((int)(cjkToJis [value + 1])) << 8);
                }
                else if (ch >= 0xE000 && ch <= 0xE757)
                {
                    // PrivateUse
                    int diff = ch - 0xE000;
                    value = ((diff / 0xBC) << 8) + (diff % 0xBC) + 0xF040;
                    if (value % 0x100 >= 0x7F)
                    {
                        value++;
                    }
                }
                else if (ch >= 0xFF01 && ch <= 0xFF60)
                {
                    value = (ch - 0xFF01) * 2;
                    value = ((int)(extraToJis [value])) | (((int)(extraToJis [value + 1])) << 8);
                }
                else if (ch >= 0xFF60 && ch <= 0xFFA0)
                {
                    value = ch - 0xFF60 + 0xA0;
                }
                else
                {
                    // Invalid character.
                    value = 0;
                }

                if (value == 0)
                {
                    HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref posn, ref byteCount, null);
                }
                else if (value < 0x0100)
                {
                    bytes [posn++] = (byte)value;
                }
                else if ((posn + 1) >= byteLength)
                {
                    throw new ArgumentException("Insufficient space available.", "bytes");
                }
                else if (value < 0x8000)
                {
                    // JIS X 0208 character.
                    value -= 0x0100;
                    ch     = (value / 0xBC);

                    value = (value % 0xBC) + 0x40;
                    if (value >= 0x7F)
                    {
                        ++value;
                    }

                    if (ch < (0x9F - 0x80))
                    {
                        bytes [posn++] = (byte)(ch + 0x81);
                    }
                    else
                    {
                        bytes [posn++] = (byte)(ch - (0x9F - 0x80) + 0xE0);
                    }
                    bytes [posn++] = (byte)value;
                }
                else if (value >= 0xF040 && value <= 0xF9FC)
                {
                    // PrivateUse
                    bytes [posn++] = (byte)(value / 0x100);
                    bytes [posn++] = (byte)(value % 0x100);
                }
                else
                {
                    // JIS X 0212 character, which Shift-JIS doesn't
                    // support, but we've already allocated two slots.
                    bytes [posn++] = (byte)'?';
                    bytes [posn++] = (byte)'?';
                }
            }

            // Return the final length to the caller.
            return(posn - byteIndex);
        }
コード例 #31
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 128)
                {
                    switch (ch)
                    {
                    case 0x00A0:
                        ch = 0x9A;
                        break;

                    case 0x00A9:
                        ch = 0xBF;
                        break;

                    case 0x00B0:
                        ch = 0x9C;
                        break;

                    case 0x00B2:
                        ch = 0x9D;
                        break;

                    case 0x00B7:
                        ch = 0x9E;
                        break;

                    case 0x00F7:
                        ch = 0x9F;
                        break;

                    case 0x0401:
                        ch = 0xB3;
                        break;

                    case 0x0410:
                        ch = 0xE1;
                        break;

                    case 0x0411:
                        ch = 0xE2;
                        break;

                    case 0x0412:
                        ch = 0xF7;
                        break;

                    case 0x0413:
                        ch = 0xE7;
                        break;

                    case 0x0414:
                        ch = 0xE4;
                        break;

                    case 0x0415:
                        ch = 0xE5;
                        break;

                    case 0x0416:
                        ch = 0xF6;
                        break;

                    case 0x0417:
                        ch = 0xFA;
                        break;

                    case 0x0418:
                    case 0x0419:
                    case 0x041A:
                    case 0x041B:
                    case 0x041C:
                    case 0x041D:
                    case 0x041E:
                    case 0x041F:
                        ch -= 0x032F;
                        break;

                    case 0x0420:
                    case 0x0421:
                    case 0x0422:
                    case 0x0423:
                        ch -= 0x032E;
                        break;

                    case 0x0424:
                        ch = 0xE6;
                        break;

                    case 0x0425:
                        ch = 0xE8;
                        break;

                    case 0x0426:
                        ch = 0xE3;
                        break;

                    case 0x0427:
                        ch = 0xFE;
                        break;

                    case 0x0428:
                        ch = 0xFB;
                        break;

                    case 0x0429:
                        ch = 0xFD;
                        break;

                    case 0x042A:
                        ch = 0xFF;
                        break;

                    case 0x042B:
                        ch = 0xF9;
                        break;

                    case 0x042C:
                        ch = 0xF8;
                        break;

                    case 0x042D:
                        ch = 0xFC;
                        break;

                    case 0x042E:
                        ch = 0xE0;
                        break;

                    case 0x042F:
                        ch = 0xF1;
                        break;

                    case 0x0430:
                        ch = 0xC1;
                        break;

                    case 0x0431:
                        ch = 0xC2;
                        break;

                    case 0x0432:
                        ch = 0xD7;
                        break;

                    case 0x0433:
                        ch = 0xC7;
                        break;

                    case 0x0434:
                        ch = 0xC4;
                        break;

                    case 0x0435:
                        ch = 0xC5;
                        break;

                    case 0x0436:
                        ch = 0xD6;
                        break;

                    case 0x0437:
                        ch = 0xDA;
                        break;

                    case 0x0438:
                    case 0x0439:
                    case 0x043A:
                    case 0x043B:
                    case 0x043C:
                    case 0x043D:
                    case 0x043E:
                    case 0x043F:
                        ch -= 0x036F;
                        break;

                    case 0x0440:
                    case 0x0441:
                    case 0x0442:
                    case 0x0443:
                        ch -= 0x036E;
                        break;

                    case 0x0444:
                        ch = 0xC6;
                        break;

                    case 0x0445:
                        ch = 0xC8;
                        break;

                    case 0x0446:
                        ch = 0xC3;
                        break;

                    case 0x0447:
                        ch = 0xDE;
                        break;

                    case 0x0448:
                        ch = 0xDB;
                        break;

                    case 0x0449:
                        ch = 0xDD;
                        break;

                    case 0x044A:
                        ch = 0xDF;
                        break;

                    case 0x044B:
                        ch = 0xD9;
                        break;

                    case 0x044C:
                        ch = 0xD8;
                        break;

                    case 0x044D:
                        ch = 0xDC;
                        break;

                    case 0x044E:
                        ch = 0xC0;
                        break;

                    case 0x044F:
                        ch = 0xD1;
                        break;

                    case 0x0451:
                        ch = 0xA3;
                        break;

                    case 0x2219:
                        ch = 0x95;
                        break;

                    case 0x221A:
                        ch = 0x96;
                        break;

                    case 0x2248:
                        ch = 0x97;
                        break;

                    case 0x2264:
                        ch = 0x98;
                        break;

                    case 0x2265:
                        ch = 0x99;
                        break;

                    case 0x2320:
                        ch = 0x93;
                        break;

                    case 0x2321:
                        ch = 0x9B;
                        break;

                    case 0x2500:
                        ch = 0x80;
                        break;

                    case 0x2502:
                        ch = 0x81;
                        break;

                    case 0x250C:
                        ch = 0x82;
                        break;

                    case 0x2510:
                        ch = 0x83;
                        break;

                    case 0x2514:
                        ch = 0x84;
                        break;

                    case 0x2518:
                        ch = 0x85;
                        break;

                    case 0x251C:
                        ch = 0x86;
                        break;

                    case 0x2524:
                        ch = 0x87;
                        break;

                    case 0x252C:
                        ch = 0x88;
                        break;

                    case 0x2534:
                        ch = 0x89;
                        break;

                    case 0x253C:
                        ch = 0x8A;
                        break;

                    case 0x2550:
                        ch = 0xA0;
                        break;

                    case 0x2551:
                        ch = 0xA1;
                        break;

                    case 0x2552:
                        ch = 0xA2;
                        break;

                    case 0x2553:
                    case 0x2554:
                    case 0x2555:
                    case 0x2556:
                    case 0x2557:
                    case 0x2558:
                    case 0x2559:
                    case 0x255A:
                    case 0x255B:
                    case 0x255C:
                    case 0x255D:
                    case 0x255E:
                    case 0x255F:
                    case 0x2560:
                    case 0x2561:
                        ch -= 0x24AF;
                        break;

                    case 0x2562:
                    case 0x2563:
                    case 0x2564:
                    case 0x2565:
                    case 0x2566:
                    case 0x2567:
                    case 0x2568:
                    case 0x2569:
                    case 0x256A:
                    case 0x256B:
                    case 0x256C:
                        ch -= 0x24AE;
                        break;

                    case 0x2580:
                        ch = 0x8B;
                        break;

                    case 0x2584:
                        ch = 0x8C;
                        break;

                    case 0x2588:
                        ch = 0x8D;
                        break;

                    case 0x258C:
                        ch = 0x8E;
                        break;

                    case 0x2590:
                    case 0x2591:
                    case 0x2592:
                    case 0x2593:
                        ch -= 0x2501;
                        break;

                    case 0x25A0:
                        ch = 0x94;
                        break;

                    case 0xFFE8:
                        ch = 0x81;
                        break;

                    case 0xFFED:
                        ch = 0x94;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #32
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 161)
                {
                    switch (ch)
                    {
                    case 0x00A3:
                    case 0x00A6:
                    case 0x00A7:
                    case 0x00A8:
                    case 0x00A9:
                    case 0x00AB:
                    case 0x00AC:
                    case 0x00AD:
                    case 0x00B0:
                    case 0x00B1:
                    case 0x00B2:
                    case 0x00B3:
                    case 0x00B4:
                    case 0x00B7:
                    case 0x00BB:
                    case 0x00BD:
                        break;

                    case 0x0385:
                    case 0x0386:
                    case 0x0387:
                    case 0x0388:
                    case 0x0389:
                    case 0x038A:
                        ch -= 0x02D0;
                        break;

                    case 0x038C:
                        ch = 0xBC;
                        break;

                    case 0x038E:
                    case 0x038F:
                    case 0x0390:
                    case 0x0391:
                    case 0x0392:
                    case 0x0393:
                    case 0x0394:
                    case 0x0395:
                    case 0x0396:
                    case 0x0397:
                    case 0x0398:
                    case 0x0399:
                    case 0x039A:
                    case 0x039B:
                    case 0x039C:
                    case 0x039D:
                    case 0x039E:
                    case 0x039F:
                    case 0x03A0:
                    case 0x03A1:
                        ch -= 0x02D0;
                        break;

                    case 0x03A3:
                    case 0x03A4:
                    case 0x03A5:
                    case 0x03A6:
                    case 0x03A7:
                    case 0x03A8:
                    case 0x03A9:
                    case 0x03AA:
                    case 0x03AB:
                    case 0x03AC:
                    case 0x03AD:
                    case 0x03AE:
                    case 0x03AF:
                    case 0x03B0:
                    case 0x03B1:
                    case 0x03B2:
                    case 0x03B3:
                    case 0x03B4:
                    case 0x03B5:
                    case 0x03B6:
                    case 0x03B7:
                    case 0x03B8:
                    case 0x03B9:
                    case 0x03BA:
                    case 0x03BB:
                    case 0x03BC:
                    case 0x03BD:
                    case 0x03BE:
                    case 0x03BF:
                    case 0x03C0:
                    case 0x03C1:
                    case 0x03C2:
                    case 0x03C3:
                    case 0x03C4:
                    case 0x03C5:
                    case 0x03C6:
                    case 0x03C7:
                    case 0x03C8:
                    case 0x03C9:
                    case 0x03CA:
                    case 0x03CB:
                    case 0x03CC:
                    case 0x03CD:
                    case 0x03CE:
                        ch -= 0x02D0;
                        break;

                    case 0x03D5:
                        ch = 0xF6;
                        break;

                    case 0x2015:
                        ch = 0xAF;
                        break;

                    case 0x2018:
                        ch = 0xA1;
                        break;

                    case 0x2019:
                        ch = 0xA2;
                        break;

                    case 0x20AC:
                        ch = 0xA4;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #33
0
        public unsafe override int GetBytesImpl(char *chars, int charCount, byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 128)
                {
                    switch (ch)
                    {
                    case 0x00A2:
                    case 0x00A3:
                    case 0x00A9:
                    case 0x00B1:
                    case 0x00B5:
                    case 0x00DE:
                        break;

                    case 0x00A0:
                        ch = 0xCA;
                        break;

                    case 0x00A1:
                        ch = 0xC1;
                        break;

                    case 0x00A4:
                        ch = 0xDB;
                        break;

                    case 0x00A5:
                        ch = 0xB4;
                        break;

                    case 0x00A7:
                        ch = 0xA4;
                        break;

                    case 0x00A8:
                        ch = 0xAC;
                        break;

                    case 0x00AA:
                        ch = 0xBB;
                        break;

                    case 0x00AB:
                        ch = 0xC7;
                        break;

                    case 0x00AC:
                        ch = 0xC2;
                        break;

                    case 0x00AE:
                        ch = 0xA8;
                        break;

                    case 0x00AF:
                        ch = 0xF8;
                        break;

                    case 0x00B0:
                        ch = 0xA1;
                        break;

                    case 0x00B4:
                        ch = 0xAB;
                        break;

                    case 0x00B6:
                        ch = 0xA6;
                        break;

                    case 0x00B7:
                        ch = 0xE1;
                        break;

                    case 0x00B8:
                        ch = 0xFC;
                        break;

                    case 0x00BA:
                        ch = 0xBC;
                        break;

                    case 0x00BB:
                        ch = 0xC8;
                        break;

                    case 0x00BF:
                        ch = 0xC0;
                        break;

                    case 0x00C0:
                        ch = 0xCB;
                        break;

                    case 0x00C1:
                        ch = 0xE7;
                        break;

                    case 0x00C2:
                        ch = 0xE5;
                        break;

                    case 0x00C3:
                        ch = 0xCC;
                        break;

                    case 0x00C4:
                        ch = 0x80;
                        break;

                    case 0x00C5:
                        ch = 0x81;
                        break;

                    case 0x00C6:
                        ch = 0xAE;
                        break;

                    case 0x00C7:
                        ch = 0x82;
                        break;

                    case 0x00C8:
                        ch = 0xE9;
                        break;

                    case 0x00C9:
                        ch = 0x83;
                        break;

                    case 0x00CA:
                        ch = 0xE6;
                        break;

                    case 0x00CB:
                        ch = 0xE8;
                        break;

                    case 0x00CC:
                        ch = 0xED;
                        break;

                    case 0x00CD:
                        ch = 0xEA;
                        break;

                    case 0x00CE:
                        ch = 0xEB;
                        break;

                    case 0x00CF:
                        ch = 0xEC;
                        break;

                    case 0x00D0:
                        ch = 0xDC;
                        break;

                    case 0x00D1:
                        ch = 0x84;
                        break;

                    case 0x00D2:
                        ch = 0xF1;
                        break;

                    case 0x00D3:
                        ch = 0xEE;
                        break;

                    case 0x00D4:
                        ch = 0xEF;
                        break;

                    case 0x00D5:
                        ch = 0xCD;
                        break;

                    case 0x00D6:
                        ch = 0x85;
                        break;

                    case 0x00D8:
                        ch = 0xAF;
                        break;

                    case 0x00D9:
                        ch = 0xF4;
                        break;

                    case 0x00DA:
                        ch = 0xF2;
                        break;

                    case 0x00DB:
                        ch = 0xF3;
                        break;

                    case 0x00DC:
                        ch = 0x86;
                        break;

                    case 0x00DD:
                        ch = 0xA0;
                        break;

                    case 0x00DF:
                        ch = 0xA7;
                        break;

                    case 0x00E0:
                        ch = 0x88;
                        break;

                    case 0x00E1:
                        ch = 0x87;
                        break;

                    case 0x00E2:
                        ch = 0x89;
                        break;

                    case 0x00E3:
                        ch = 0x8B;
                        break;

                    case 0x00E4:
                        ch = 0x8A;
                        break;

                    case 0x00E5:
                        ch = 0x8C;
                        break;

                    case 0x00E6:
                        ch = 0xBE;
                        break;

                    case 0x00E7:
                        ch = 0x8D;
                        break;

                    case 0x00E8:
                        ch = 0x8F;
                        break;

                    case 0x00E9:
                        ch = 0x8E;
                        break;

                    case 0x00EA:
                        ch = 0x90;
                        break;

                    case 0x00EB:
                        ch = 0x91;
                        break;

                    case 0x00EC:
                        ch = 0x93;
                        break;

                    case 0x00ED:
                        ch = 0x92;
                        break;

                    case 0x00EE:
                        ch = 0x94;
                        break;

                    case 0x00EF:
                        ch = 0x95;
                        break;

                    case 0x00F0:
                        ch = 0xDD;
                        break;

                    case 0x00F1:
                        ch = 0x96;
                        break;

                    case 0x00F2:
                        ch = 0x98;
                        break;

                    case 0x00F3:
                        ch = 0x97;
                        break;

                    case 0x00F4:
                        ch = 0x99;
                        break;

                    case 0x00F5:
                        ch = 0x9B;
                        break;

                    case 0x00F6:
                        ch = 0x9A;
                        break;

                    case 0x00F7:
                        ch = 0xD6;
                        break;

                    case 0x00F8:
                        ch = 0xBF;
                        break;

                    case 0x00F9:
                        ch = 0x9D;
                        break;

                    case 0x00FA:
                        ch = 0x9C;
                        break;

                    case 0x00FB:
                        ch = 0x9E;
                        break;

                    case 0x00FC:
                        ch = 0x9F;
                        break;

                    case 0x00FD:
                        ch = 0xE0;
                        break;

                    case 0x00FE:
                        ch = 0xDF;
                        break;

                    case 0x00FF:
                        ch = 0xD8;
                        break;

                    case 0x0131:
                        ch = 0xF5;
                        break;

                    case 0x0152:
                        ch = 0xCE;
                        break;

                    case 0x0153:
                        ch = 0xCF;
                        break;

                    case 0x0178:
                        ch = 0xD9;
                        break;

                    case 0x0192:
                        ch = 0xC4;
                        break;

                    case 0x02C6:
                        ch = 0xF6;
                        break;

                    case 0x02C7:
                        ch = 0xFF;
                        break;

                    case 0x02D8:
                        ch = 0xF9;
                        break;

                    case 0x02D9:
                        ch = 0xFA;
                        break;

                    case 0x02DA:
                        ch = 0xFB;
                        break;

                    case 0x02DB:
                        ch = 0xFE;
                        break;

                    case 0x02DC:
                        ch = 0xF7;
                        break;

                    case 0x02DD:
                        ch = 0xFD;
                        break;

                    case 0x03C0:
                        ch = 0xB9;
                        break;

                    case 0x2013:
                        ch = 0xD0;
                        break;

                    case 0x2014:
                        ch = 0xD1;
                        break;

                    case 0x2018:
                        ch = 0xD4;
                        break;

                    case 0x2019:
                        ch = 0xD5;
                        break;

                    case 0x201A:
                        ch = 0xE2;
                        break;

                    case 0x201C:
                        ch = 0xD2;
                        break;

                    case 0x201D:
                        ch = 0xD3;
                        break;

                    case 0x201E:
                        ch = 0xE3;
                        break;

                    case 0x2022:
                        ch = 0xA5;
                        break;

                    case 0x2026:
                        ch = 0xC9;
                        break;

                    case 0x2030:
                        ch = 0xE4;
                        break;

                    case 0x2044:
                        ch = 0xDA;
                        break;

                    case 0x2122:
                        ch = 0xAA;
                        break;

                    case 0x2126:
                        ch = 0xBD;
                        break;

                    case 0x2202:
                        ch = 0xB6;
                        break;

                    case 0x2206:
                        ch = 0xC6;
                        break;

                    case 0x220F:
                        ch = 0xB8;
                        break;

                    case 0x2211:
                        ch = 0xB7;
                        break;

                    case 0x221A:
                        ch = 0xC3;
                        break;

                    case 0x221E:
                        ch = 0xB0;
                        break;

                    case 0x222B:
                        ch = 0xBA;
                        break;

                    case 0x2248:
                        ch = 0xC5;
                        break;

                    case 0x2260:
                        ch = 0xAD;
                        break;

                    case 0x2264:
                        ch = 0xB2;
                        break;

                    case 0x2265:
                        ch = 0xB3;
                        break;

                    case 0x25CA:
                        ch = 0xD7;
                        break;

                    case 0xF8FF:
                        ch = 0xF0;
                        break;

                    default:
                        HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                        continue;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #34
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 128)
                {
                    switch (ch)
                    {
                    case 0x0081:
                    case 0x0083:
                    case 0x0088:
                    case 0x008A:
                    case 0x008C:
                    case 0x0090:
                    case 0x0098:
                    case 0x009A:
                    case 0x009C:
                    case 0x009F:
                    case 0x00A0:
                    case 0x00A2:
                    case 0x00A3:
                    case 0x00A4:
                    case 0x00A6:
                    case 0x00A7:
                    case 0x00A9:
                    case 0x00AB:
                    case 0x00AC:
                    case 0x00AD:
                    case 0x00AE:
                    case 0x00B0:
                    case 0x00B1:
                    case 0x00B2:
                    case 0x00B3:
                    case 0x00B4:
                    case 0x00B5:
                    case 0x00B6:
                    case 0x00B7:
                    case 0x00B9:
                    case 0x00BB:
                    case 0x00BC:
                    case 0x00BD:
                    case 0x00BE:
                    case 0x00C4:
                    case 0x00C5:
                    case 0x00C9:
                    case 0x00D3:
                    case 0x00D5:
                    case 0x00D6:
                    case 0x00D7:
                    case 0x00DC:
                    case 0x00DF:
                    case 0x00E4:
                    case 0x00E5:
                    case 0x00E9:
                    case 0x00F3:
                    case 0x00F5:
                    case 0x00F6:
                    case 0x00F7:
                    case 0x00FC:
                        break;

                    case 0x00A8:
                        ch = 0x8D;
                        break;

                    case 0x00AF:
                        ch = 0x9D;
                        break;

                    case 0x00B8:
                        ch = 0x8F;
                        break;

                    case 0x00C6:
                        ch = 0xAF;
                        break;

                    case 0x00D8:
                        ch = 0xA8;
                        break;

                    case 0x00E6:
                        ch = 0xBF;
                        break;

                    case 0x00F8:
                        ch = 0xB8;
                        break;

                    case 0x0100:
                        ch = 0xC2;
                        break;

                    case 0x0101:
                        ch = 0xE2;
                        break;

                    case 0x0104:
                        ch = 0xC0;
                        break;

                    case 0x0105:
                        ch = 0xE0;
                        break;

                    case 0x0106:
                        ch = 0xC3;
                        break;

                    case 0x0107:
                        ch = 0xE3;
                        break;

                    case 0x010C:
                        ch = 0xC8;
                        break;

                    case 0x010D:
                        ch = 0xE8;
                        break;

                    case 0x0112:
                        ch = 0xC7;
                        break;

                    case 0x0113:
                        ch = 0xE7;
                        break;

                    case 0x0116:
                        ch = 0xCB;
                        break;

                    case 0x0117:
                        ch = 0xEB;
                        break;

                    case 0x0118:
                        ch = 0xC6;
                        break;

                    case 0x0119:
                        ch = 0xE6;
                        break;

                    case 0x0122:
                        ch = 0xCC;
                        break;

                    case 0x0123:
                        ch = 0xEC;
                        break;

                    case 0x012A:
                        ch = 0xCE;
                        break;

                    case 0x012B:
                        ch = 0xEE;
                        break;

                    case 0x012E:
                        ch = 0xC1;
                        break;

                    case 0x012F:
                        ch = 0xE1;
                        break;

                    case 0x0136:
                        ch = 0xCD;
                        break;

                    case 0x0137:
                        ch = 0xED;
                        break;

                    case 0x013B:
                        ch = 0xCF;
                        break;

                    case 0x013C:
                        ch = 0xEF;
                        break;

                    case 0x0141:
                        ch = 0xD9;
                        break;

                    case 0x0142:
                        ch = 0xF9;
                        break;

                    case 0x0143:
                        ch = 0xD1;
                        break;

                    case 0x0144:
                        ch = 0xF1;
                        break;

                    case 0x0145:
                        ch = 0xD2;
                        break;

                    case 0x0146:
                        ch = 0xF2;
                        break;

                    case 0x014C:
                        ch = 0xD4;
                        break;

                    case 0x014D:
                        ch = 0xF4;
                        break;

                    case 0x0156:
                        ch = 0xAA;
                        break;

                    case 0x0157:
                        ch = 0xBA;
                        break;

                    case 0x015A:
                        ch = 0xDA;
                        break;

                    case 0x015B:
                        ch = 0xFA;
                        break;

                    case 0x0160:
                        ch = 0xD0;
                        break;

                    case 0x0161:
                        ch = 0xF0;
                        break;

                    case 0x016A:
                        ch = 0xDB;
                        break;

                    case 0x016B:
                        ch = 0xFB;
                        break;

                    case 0x0172:
                        ch = 0xD8;
                        break;

                    case 0x0173:
                        ch = 0xF8;
                        break;

                    case 0x0179:
                        ch = 0xCA;
                        break;

                    case 0x017A:
                        ch = 0xEA;
                        break;

                    case 0x017B:
                        ch = 0xDD;
                        break;

                    case 0x017C:
                        ch = 0xFD;
                        break;

                    case 0x017D:
                        ch = 0xDE;
                        break;

                    case 0x017E:
                        ch = 0xFE;
                        break;

                    case 0x02C7:
                        ch = 0x8E;
                        break;

                    case 0x02D9:
                        ch = 0xFF;
                        break;

                    case 0x02DB:
                        ch = 0x9E;
                        break;

                    case 0x2013:
                        ch = 0x96;
                        break;

                    case 0x2014:
                        ch = 0x97;
                        break;

                    case 0x2018:
                        ch = 0x91;
                        break;

                    case 0x2019:
                        ch = 0x92;
                        break;

                    case 0x201A:
                        ch = 0x82;
                        break;

                    case 0x201C:
                        ch = 0x93;
                        break;

                    case 0x201D:
                        ch = 0x94;
                        break;

                    case 0x201E:
                        ch = 0x84;
                        break;

                    case 0x2020:
                        ch = 0x86;
                        break;

                    case 0x2021:
                        ch = 0x87;
                        break;

                    case 0x2022:
                        ch = 0x95;
                        break;

                    case 0x2026:
                        ch = 0x85;
                        break;

                    case 0x2030:
                        ch = 0x89;
                        break;

                    case 0x2039:
                        ch = 0x8B;
                        break;

                    case 0x203A:
                        ch = 0x9B;
                        break;

                    case 0x20AC:
                        ch = 0x80;
                        break;

                    case 0x2122:
                        ch = 0x99;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #35
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 128)
                {
                    switch (ch)
                    {
                    case 0x0081:
                    case 0x008A:
                    case 0x008D:
                    case 0x008E:
                    case 0x008F:
                    case 0x0090:
                    case 0x009A:
                    case 0x009D:
                    case 0x009E:
                    case 0x00A0:
                    case 0x00A1:
                    case 0x00A2:
                    case 0x00A3:
                    case 0x00A4:
                    case 0x00A5:
                    case 0x00A6:
                    case 0x00A7:
                    case 0x00A8:
                    case 0x00A9:
                    case 0x00AA:
                    case 0x00AB:
                    case 0x00AC:
                    case 0x00AD:
                    case 0x00AE:
                    case 0x00AF:
                    case 0x00B0:
                    case 0x00B1:
                    case 0x00B2:
                    case 0x00B3:
                    case 0x00B4:
                    case 0x00B5:
                    case 0x00B6:
                    case 0x00B7:
                    case 0x00B8:
                    case 0x00B9:
                    case 0x00BA:
                    case 0x00BB:
                    case 0x00BC:
                    case 0x00BD:
                    case 0x00BE:
                    case 0x00BF:
                    case 0x00C0:
                    case 0x00C1:
                    case 0x00C2:
                    case 0x00C4:
                    case 0x00C5:
                    case 0x00C6:
                    case 0x00C7:
                    case 0x00C8:
                    case 0x00C9:
                    case 0x00CA:
                    case 0x00CB:
                    case 0x00CD:
                    case 0x00CE:
                    case 0x00CF:
                    case 0x00D1:
                    case 0x00D3:
                    case 0x00D4:
                    case 0x00D6:
                    case 0x00D7:
                    case 0x00D8:
                    case 0x00D9:
                    case 0x00DA:
                    case 0x00DB:
                    case 0x00DC:
                    case 0x00DF:
                    case 0x00E0:
                    case 0x00E1:
                    case 0x00E2:
                    case 0x00E4:
                    case 0x00E5:
                    case 0x00E6:
                    case 0x00E7:
                    case 0x00E8:
                    case 0x00E9:
                    case 0x00EA:
                    case 0x00EB:
                    case 0x00ED:
                    case 0x00EE:
                    case 0x00EF:
                    case 0x00F1:
                    case 0x00F3:
                    case 0x00F4:
                    case 0x00F6:
                    case 0x00F7:
                    case 0x00F8:
                    case 0x00F9:
                    case 0x00FA:
                    case 0x00FB:
                    case 0x00FC:
                    case 0x00FF:
                        break;

                    case 0x0102:
                        ch = 0xC3;
                        break;

                    case 0x0103:
                        ch = 0xE3;
                        break;

                    case 0x0110:
                        ch = 0xD0;
                        break;

                    case 0x0111:
                        ch = 0xF0;
                        break;

                    case 0x0152:
                        ch = 0x8C;
                        break;

                    case 0x0153:
                        ch = 0x9C;
                        break;

                    case 0x0178:
                        ch = 0x9F;
                        break;

                    case 0x0192:
                        ch = 0x83;
                        break;

                    case 0x01A0:
                        ch = 0xD5;
                        break;

                    case 0x01A1:
                        ch = 0xF5;
                        break;

                    case 0x01AF:
                        ch = 0xDD;
                        break;

                    case 0x01B0:
                        ch = 0xFD;
                        break;

                    case 0x02C6:
                        ch = 0x88;
                        break;

                    case 0x02DC:
                        ch = 0x98;
                        break;

                    case 0x0300:
                        ch = 0xCC;
                        break;

                    case 0x0301:
                        ch = 0xEC;
                        break;

                    case 0x0303:
                        ch = 0xDE;
                        break;

                    case 0x0309:
                        ch = 0xD2;
                        break;

                    case 0x0323:
                        ch = 0xF2;
                        break;

                    case 0x2013:
                        ch = 0x96;
                        break;

                    case 0x2014:
                        ch = 0x97;
                        break;

                    case 0x2018:
                        ch = 0x91;
                        break;

                    case 0x2019:
                        ch = 0x92;
                        break;

                    case 0x201A:
                        ch = 0x82;
                        break;

                    case 0x201C:
                        ch = 0x93;
                        break;

                    case 0x201D:
                        ch = 0x94;
                        break;

                    case 0x201E:
                        ch = 0x84;
                        break;

                    case 0x2020:
                        ch = 0x86;
                        break;

                    case 0x2021:
                        ch = 0x87;
                        break;

                    case 0x2022:
                        ch = 0x95;
                        break;

                    case 0x2026:
                        ch = 0x85;
                        break;

                    case 0x2030:
                        ch = 0x89;
                        break;

                    case 0x2039:
                        ch = 0x8B;
                        break;

                    case 0x203A:
                        ch = 0x9B;
                        break;

                    case 0x20AB:
                        ch = 0xFE;
                        break;

                    case 0x20AC:
                        ch = 0x80;
                        break;

                    case 0x2122:
                        ch = 0x99;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #36
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 164)
                {
                    switch (ch)
                    {
                    case 0x00A5:
                    case 0x00A7:
                    case 0x00A9:
                    case 0x00AA:
                    case 0x00AB:
                    case 0x00AC:
                    case 0x00AD:
                    case 0x00AE:
                    case 0x00AF:
                    case 0x00B0:
                    case 0x00B1:
                    case 0x00B2:
                    case 0x00B3:
                    case 0x00B5:
                    case 0x00B6:
                    case 0x00B7:
                    case 0x00B9:
                    case 0x00BA:
                    case 0x00BB:
                    case 0x00BF:
                    case 0x00C0:
                    case 0x00C1:
                    case 0x00C2:
                    case 0x00C3:
                    case 0x00C4:
                    case 0x00C5:
                    case 0x00C6:
                    case 0x00C7:
                    case 0x00C8:
                    case 0x00C9:
                    case 0x00CA:
                    case 0x00CB:
                    case 0x00CC:
                    case 0x00CD:
                    case 0x00CE:
                    case 0x00CF:
                    case 0x00D0:
                    case 0x00D1:
                    case 0x00D2:
                    case 0x00D3:
                    case 0x00D4:
                    case 0x00D5:
                    case 0x00D6:
                    case 0x00D7:
                    case 0x00D8:
                    case 0x00D9:
                    case 0x00DA:
                    case 0x00DB:
                    case 0x00DC:
                    case 0x00DD:
                    case 0x00DE:
                    case 0x00DF:
                    case 0x00E0:
                    case 0x00E1:
                    case 0x00E2:
                    case 0x00E3:
                    case 0x00E4:
                    case 0x00E5:
                    case 0x00E6:
                    case 0x00E7:
                    case 0x00E8:
                    case 0x00E9:
                    case 0x00EA:
                    case 0x00EB:
                    case 0x00EC:
                    case 0x00ED:
                    case 0x00EE:
                    case 0x00EF:
                    case 0x00F0:
                    case 0x00F1:
                    case 0x00F2:
                    case 0x00F3:
                    case 0x00F4:
                    case 0x00F5:
                    case 0x00F6:
                    case 0x00F7:
                    case 0x00F8:
                    case 0x00F9:
                    case 0x00FA:
                    case 0x00FB:
                    case 0x00FC:
                    case 0x00FD:
                    case 0x00FE:
                    case 0x00FF:
                        break;

                    case 0x0152:
                        ch = 0xBC;
                        break;

                    case 0x0153:
                        ch = 0xBD;
                        break;

                    case 0x0160:
                        ch = 0xA6;
                        break;

                    case 0x0161:
                        ch = 0xA8;
                        break;

                    case 0x0178:
                        ch = 0xBE;
                        break;

                    case 0x017D:
                        ch = 0xB4;
                        break;

                    case 0x017E:
                        ch = 0xB8;
                        break;

                    case 0x20AC:
                        ch = 0xA4;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }
コード例 #37
0
        public unsafe override int GetBytesImpl(char *chars, int charCount,
                                                byte *bytes, int byteCount)
        {
            int ch;
            int charIndex = 0;
            int byteIndex = 0;
            EncoderFallbackBuffer buffer = null;

            while (charCount > 0)
            {
                ch = (int)(chars [charIndex]);
                charIndex++;
                charCount--;
                if (ch >= 128)
                {
                    switch (ch)
                    {
                    case 0x00A0:
                    case 0x00A2:
                    case 0x00A3:
                    case 0x00A4:
                    case 0x00A5:
                    case 0x00A6:
                    case 0x00A7:
                    case 0x00A8:
                    case 0x00A9:
                    case 0x00AB:
                    case 0x00AC:
                    case 0x00AD:
                    case 0x00AE:
                    case 0x00AF:
                    case 0x00B0:
                    case 0x00B1:
                    case 0x00B2:
                    case 0x00B3:
                    case 0x00B4:
                    case 0x00B5:
                    case 0x00B6:
                    case 0x00B7:
                    case 0x00B8:
                    case 0x00B9:
                    case 0x00BB:
                    case 0x00BC:
                    case 0x00BD:
                    case 0x00BE:
                    case 0x00D7:
                    case 0x00E0:
                    case 0x00E2:
                    case 0x00E7:
                    case 0x00E8:
                    case 0x00E9:
                    case 0x00EA:
                    case 0x00EB:
                    case 0x00EE:
                    case 0x00EF:
                    case 0x00F4:
                    case 0x00F7:
                    case 0x00F9:
                    case 0x00FB:
                    case 0x00FC:
                        break;

                    case 0x0152:
                        ch = 0x8C;
                        break;

                    case 0x0153:
                        ch = 0x9C;
                        break;

                    case 0x0192:
                        ch = 0x83;
                        break;

                    case 0x02C6:
                        ch = 0x88;
                        break;

                    case 0x060C:
                        ch = 0xA1;
                        break;

                    case 0x061B:
                        ch = 0xBA;
                        break;

                    case 0x061F:
                        ch = 0xBF;
                        break;

                    case 0x0621:
                    case 0x0622:
                    case 0x0623:
                    case 0x0624:
                    case 0x0625:
                    case 0x0626:
                    case 0x0627:
                    case 0x0628:
                    case 0x0629:
                    case 0x062A:
                    case 0x062B:
                    case 0x062C:
                    case 0x062D:
                    case 0x062E:
                    case 0x062F:
                    case 0x0630:
                    case 0x0631:
                    case 0x0632:
                    case 0x0633:
                    case 0x0634:
                    case 0x0635:
                    case 0x0636:
                        ch -= 0x0560;
                        break;

                    case 0x0637:
                    case 0x0638:
                    case 0x0639:
                    case 0x063A:
                        ch -= 0x055F;
                        break;

                    case 0x0640:
                    case 0x0641:
                    case 0x0642:
                    case 0x0643:
                        ch -= 0x0564;
                        break;

                    case 0x0644:
                        ch = 0xE1;
                        break;

                    case 0x0645:
                    case 0x0646:
                    case 0x0647:
                    case 0x0648:
                        ch -= 0x0562;
                        break;

                    case 0x0649:
                        ch = 0xEC;
                        break;

                    case 0x064A:
                        ch = 0xED;
                        break;

                    case 0x064B:
                    case 0x064C:
                    case 0x064D:
                    case 0x064E:
                        ch -= 0x055B;
                        break;

                    case 0x064F:
                        ch = 0xF5;
                        break;

                    case 0x0650:
                        ch = 0xF6;
                        break;

                    case 0x0651:
                        ch = 0xF8;
                        break;

                    case 0x0652:
                        ch = 0xFA;
                        break;

                    case 0x0660:
                    case 0x0661:
                    case 0x0662:
                    case 0x0663:
                    case 0x0664:
                    case 0x0665:
                    case 0x0666:
                    case 0x0667:
                    case 0x0668:
                    case 0x0669:
                        ch -= 0x0630;
                        break;

                    case 0x066B:
                        ch = 0x2C;
                        break;

                    case 0x066C:
                        ch = 0x2E;
                        break;

                    case 0x0679:
                        ch = 0x8A;
                        break;

                    case 0x067E:
                        ch = 0x81;
                        break;

                    case 0x0686:
                        ch = 0x8D;
                        break;

                    case 0x0688:
                        ch = 0x8F;
                        break;

                    case 0x0691:
                        ch = 0x9A;
                        break;

                    case 0x0698:
                        ch = 0x8E;
                        break;

                    case 0x06A9:
                        ch = 0x98;
                        break;

                    case 0x06AF:
                        ch = 0x90;
                        break;

                    case 0x06BA:
                        ch = 0x9F;
                        break;

                    case 0x06BE:
                        ch = 0xAA;
                        break;

                    case 0x06C1:
                        ch = 0xC0;
                        break;

                    case 0x06D2:
                        ch = 0xFF;
                        break;

                    case 0x06F0:
                    case 0x06F1:
                    case 0x06F2:
                    case 0x06F3:
                    case 0x06F4:
                    case 0x06F5:
                    case 0x06F6:
                    case 0x06F7:
                    case 0x06F8:
                    case 0x06F9:
                        ch -= 0x06C0;
                        break;

                    case 0x200C:
                        ch = 0x9D;
                        break;

                    case 0x200D:
                        ch = 0x9E;
                        break;

                    case 0x200E:
                        ch = 0xFD;
                        break;

                    case 0x200F:
                        ch = 0xFE;
                        break;

                    case 0x2013:
                        ch = 0x96;
                        break;

                    case 0x2014:
                        ch = 0x97;
                        break;

                    case 0x2018:
                        ch = 0x91;
                        break;

                    case 0x2019:
                        ch = 0x92;
                        break;

                    case 0x201A:
                        ch = 0x82;
                        break;

                    case 0x201C:
                        ch = 0x93;
                        break;

                    case 0x201D:
                        ch = 0x94;
                        break;

                    case 0x201E:
                        ch = 0x84;
                        break;

                    case 0x2020:
                        ch = 0x86;
                        break;

                    case 0x2021:
                        ch = 0x87;
                        break;

                    case 0x2022:
                        ch = 0x95;
                        break;

                    case 0x2026:
                        ch = 0x85;
                        break;

                    case 0x2030:
                        ch = 0x89;
                        break;

                    case 0x2039:
                        ch = 0x8B;
                        break;

                    case 0x203A:
                        ch = 0x9B;
                        break;

                    case 0x20AC:
                        ch = 0x80;
                        break;

                    case 0x2122:
                        ch = 0x99;
                        break;

                    case 0xFB56:
                        ch = 0x81;
                        break;

                    case 0xFB58:
                        ch = 0x81;
                        break;

                    case 0xFB66:
                        ch = 0x8A;
                        break;

                    case 0xFB68:
                        ch = 0x8A;
                        break;

                    case 0xFB7A:
                        ch = 0x8D;
                        break;

                    case 0xFB7C:
                        ch = 0x8D;
                        break;

                    case 0xFB88:
                        ch = 0x8F;
                        break;

                    case 0xFB8A:
                        ch = 0x8E;
                        break;

                    case 0xFB8C:
                        ch = 0x9A;
                        break;

                    case 0xFB8E:
                        ch = 0x98;
                        break;

                    case 0xFB90:
                        ch = 0x98;
                        break;

                    case 0xFB92:
                        ch = 0x90;
                        break;

                    case 0xFB94:
                        ch = 0x90;
                        break;

                    case 0xFB9E:
                        ch = 0x9F;
                        break;

                    case 0xFBA6:
                        ch = 0xC0;
                        break;

                    case 0xFBA8:
                        ch = 0xC0;
                        break;

                    case 0xFBAA:
                        ch = 0xAA;
                        break;

                    case 0xFBAC:
                        ch = 0xAA;
                        break;

                    case 0xFBAE:
                        ch = 0xFF;
                        break;

                    case 0xFE70:
                        ch = 0xF0;
                        break;

                    case 0xFE71:
                        ch = 0xF0;
                        break;

                    case 0xFE72:
                        ch = 0xF1;
                        break;

                    case 0xFE74:
                        ch = 0xF2;
                        break;

                    case 0xFE76:
                        ch = 0xF3;
                        break;

                    case 0xFE77:
                        ch = 0xF3;
                        break;

                    case 0xFE78:
                        ch = 0xF5;
                        break;

                    case 0xFE79:
                        ch = 0xF5;
                        break;

                    case 0xFE7A:
                        ch = 0xF6;
                        break;

                    case 0xFE7B:
                        ch = 0xF6;
                        break;

                    case 0xFE7C:
                        ch = 0xF8;
                        break;

                    case 0xFE7D:
                        ch = 0xF8;
                        break;

                    case 0xFE7E:
                        ch = 0xFA;
                        break;

                    case 0xFE7F:
                        ch = 0xFA;
                        break;

                    case 0xFE80:
                        ch = 0xC1;
                        break;

                    case 0xFE81:
                        ch = 0xC2;
                        break;

                    case 0xFE82:
                        ch = 0xC2;
                        break;

                    case 0xFE83:
                        ch = 0xC3;
                        break;

                    case 0xFE84:
                        ch = 0xC3;
                        break;

                    case 0xFE85:
                        ch = 0xC4;
                        break;

                    case 0xFE86:
                        ch = 0xC4;
                        break;

                    case 0xFE87:
                        ch = 0xC5;
                        break;

                    case 0xFE88:
                        ch = 0xC5;
                        break;

                    case 0xFE89:
                        ch = 0xC6;
                        break;

                    case 0xFE8A:
                        ch = 0xC6;
                        break;

                    case 0xFE8B:
                        ch = 0xC6;
                        break;

                    case 0xFE8C:
                        ch = 0xC6;
                        break;

                    case 0xFE8D:
                        ch = 0xC7;
                        break;

                    case 0xFE8E:
                        ch = 0xC7;
                        break;

                    case 0xFE8F:
                        ch = 0xC8;
                        break;

                    case 0xFE90:
                        ch = 0xC8;
                        break;

                    case 0xFE91:
                        ch = 0xC8;
                        break;

                    case 0xFE92:
                        ch = 0xC8;
                        break;

                    case 0xFE93:
                        ch = 0xC9;
                        break;

                    case 0xFE94:
                        ch = 0xC9;
                        break;

                    case 0xFE95:
                        ch = 0xCA;
                        break;

                    case 0xFE96:
                        ch = 0xCA;
                        break;

                    case 0xFE97:
                        ch = 0xCA;
                        break;

                    case 0xFE98:
                        ch = 0xCA;
                        break;

                    case 0xFE99:
                        ch = 0xCB;
                        break;

                    case 0xFE9A:
                        ch = 0xCB;
                        break;

                    case 0xFE9B:
                        ch = 0xCB;
                        break;

                    case 0xFE9C:
                        ch = 0xCB;
                        break;

                    case 0xFE9D:
                        ch = 0xCC;
                        break;

                    case 0xFE9E:
                        ch = 0xCC;
                        break;

                    case 0xFE9F:
                        ch = 0xCC;
                        break;

                    case 0xFEA0:
                        ch = 0xCC;
                        break;

                    case 0xFEA1:
                        ch = 0xCD;
                        break;

                    case 0xFEA2:
                        ch = 0xCD;
                        break;

                    case 0xFEA3:
                        ch = 0xCD;
                        break;

                    case 0xFEA4:
                        ch = 0xCD;
                        break;

                    case 0xFEA5:
                        ch = 0xCE;
                        break;

                    case 0xFEA6:
                        ch = 0xCE;
                        break;

                    case 0xFEA7:
                        ch = 0xCE;
                        break;

                    case 0xFEA8:
                        ch = 0xCE;
                        break;

                    case 0xFEA9:
                        ch = 0xCF;
                        break;

                    case 0xFEAA:
                        ch = 0xCF;
                        break;

                    case 0xFEAB:
                        ch = 0xD0;
                        break;

                    case 0xFEAC:
                        ch = 0xD0;
                        break;

                    case 0xFEAD:
                        ch = 0xD1;
                        break;

                    case 0xFEAE:
                        ch = 0xD1;
                        break;

                    case 0xFEAF:
                        ch = 0xD2;
                        break;

                    case 0xFEB0:
                        ch = 0xD2;
                        break;

                    case 0xFEB1:
                        ch = 0xD3;
                        break;

                    case 0xFEB2:
                        ch = 0xD3;
                        break;

                    case 0xFEB3:
                        ch = 0xD3;
                        break;

                    case 0xFEB4:
                        ch = 0xD3;
                        break;

                    case 0xFEB5:
                        ch = 0xD4;
                        break;

                    case 0xFEB6:
                        ch = 0xD4;
                        break;

                    case 0xFEB7:
                        ch = 0xD4;
                        break;

                    case 0xFEB8:
                        ch = 0xD4;
                        break;

                    case 0xFEB9:
                        ch = 0xD5;
                        break;

                    case 0xFEBA:
                        ch = 0xD5;
                        break;

                    case 0xFEBB:
                        ch = 0xD5;
                        break;

                    case 0xFEBC:
                        ch = 0xD5;
                        break;

                    case 0xFEBD:
                        ch = 0xD6;
                        break;

                    case 0xFEBE:
                        ch = 0xD6;
                        break;

                    case 0xFEBF:
                        ch = 0xD6;
                        break;

                    case 0xFEC0:
                        ch = 0xD6;
                        break;

                    case 0xFEC1:
                        ch = 0xD8;
                        break;

                    case 0xFEC2:
                        ch = 0xD8;
                        break;

                    case 0xFEC3:
                        ch = 0xD8;
                        break;

                    case 0xFEC4:
                        ch = 0xD8;
                        break;

                    case 0xFEC5:
                        ch = 0xD9;
                        break;

                    case 0xFEC6:
                        ch = 0xD9;
                        break;

                    case 0xFEC7:
                        ch = 0xD9;
                        break;

                    case 0xFEC8:
                        ch = 0xD9;
                        break;

                    case 0xFEC9:
                        ch = 0xDA;
                        break;

                    case 0xFECA:
                        ch = 0xDA;
                        break;

                    case 0xFECB:
                        ch = 0xDA;
                        break;

                    case 0xFECC:
                        ch = 0xDA;
                        break;

                    case 0xFECD:
                        ch = 0xDB;
                        break;

                    case 0xFECE:
                        ch = 0xDB;
                        break;

                    case 0xFECF:
                        ch = 0xDB;
                        break;

                    case 0xFED0:
                        ch = 0xDB;
                        break;

                    case 0xFED1:
                        ch = 0xDD;
                        break;

                    case 0xFED2:
                        ch = 0xDD;
                        break;

                    case 0xFED3:
                        ch = 0xDD;
                        break;

                    case 0xFED4:
                        ch = 0xDD;
                        break;

                    case 0xFED5:
                        ch = 0xDE;
                        break;

                    case 0xFED6:
                        ch = 0xDE;
                        break;

                    case 0xFED7:
                        ch = 0xDE;
                        break;

                    case 0xFED8:
                        ch = 0xDE;
                        break;

                    case 0xFED9:
                        ch = 0xDF;
                        break;

                    case 0xFEDA:
                        ch = 0xDF;
                        break;

                    case 0xFEDB:
                        ch = 0xDF;
                        break;

                    case 0xFEDC:
                        ch = 0xDF;
                        break;

                    case 0xFEDD:
                        ch = 0xE1;
                        break;

                    case 0xFEDE:
                        ch = 0xE1;
                        break;

                    case 0xFEDF:
                        ch = 0xE1;
                        break;

                    case 0xFEE0:
                        ch = 0xE1;
                        break;

                    case 0xFEE1:
                        ch = 0xE3;
                        break;

                    case 0xFEE2:
                        ch = 0xE3;
                        break;

                    case 0xFEE3:
                        ch = 0xE3;
                        break;

                    case 0xFEE4:
                        ch = 0xE3;
                        break;

                    case 0xFEE5:
                        ch = 0xE4;
                        break;

                    case 0xFEE6:
                        ch = 0xE4;
                        break;

                    case 0xFEE7:
                        ch = 0xE4;
                        break;

                    case 0xFEE8:
                        ch = 0xE4;
                        break;

                    case 0xFEE9:
                        ch = 0xE5;
                        break;

                    case 0xFEEA:
                        ch = 0xE5;
                        break;

                    case 0xFEEB:
                        ch = 0xE5;
                        break;

                    case 0xFEEC:
                        ch = 0xE5;
                        break;

                    case 0xFEED:
                        ch = 0xE6;
                        break;

                    case 0xFEEE:
                        ch = 0xE6;
                        break;

                    case 0xFEEF:
                        ch = 0xEC;
                        break;

                    case 0xFEF0:
                        ch = 0xEC;
                        break;

                    case 0xFEF1:
                        ch = 0xED;
                        break;

                    case 0xFEF2:
                        ch = 0xED;
                        break;

                    case 0xFEF3:
                        ch = 0xED;
                        break;

                    case 0xFEF4:
                        ch = 0xED;
                        break;

                    default:
                    {
                        if (ch >= 0xFF01 && ch <= 0xFF5E)
                        {
                            ch -= 0xFEE0;
                        }
                        else
                        {
                            HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
                            continue;
                        }
                    }
                    break;
                    }
                }
                //Write encoded byte to buffer, if buffer is defined and fallback was not used
                if (bytes != null)
                {
                    bytes [byteIndex] = (byte)ch;
                }
                byteIndex++;
                byteCount--;
            }
            return(byteIndex);
        }