public static IEnumerable <Utf8Bytes> Split(this Utf8Bytes src, byte delemeter)
        {
            var start = 0;
            var p     = new Utf8Iterator(src.Bytes);

            while (p.MoveNext())
            {
                if (p.Current == delemeter)
                {
                    if (p.BytePosition - start == 0)
                    {
                        yield return(default(Utf8Bytes));
                    }
                    else
                    {
                        yield return(src.Subbytes(start, p.BytePosition - start));
                    }
                    start = p.BytePosition + 1;
                }
            }

            if (start < p.BytePosition)
            {
                yield return(src.Subbytes(start, p.BytePosition - start));
            }
        }
        public static UInt64 ToUInt64(this Utf8Bytes src)
        {
            UInt64 value = 0;
            var    p     = new Utf8Iterator(src.Bytes);

            while (p.MoveNext())
            {
                var b = p.Current;
                switch (b)
                {
                case 0x30: value = (UInt64)(value * 10); break;

                case 0x31: value = (UInt64)(value * 10 + 1); break;

                case 0x32: value = (UInt64)(value * 10 + 2); break;

                case 0x33: value = (UInt64)(value * 10 + 3); break;

                case 0x34: value = (UInt64)(value * 10 + 4); break;

                case 0x35: value = (UInt64)(value * 10 + 5); break;

                case 0x36: value = (UInt64)(value * 10 + 6); break;

                case 0x37: value = (UInt64)(value * 10 + 7); break;

                case 0x38: value = (UInt64)(value * 10 + 8); break;

                case 0x39: value = (UInt64)(value * 10 + 9); break;

                default: throw new ArgumentOutOfRangeException();
                }
            }
            return(value);
        }
        public static Int32 ToInt32(this Utf8Bytes src)
        {
            Int32 value = 0;
            var   p     = new Utf8Iterator(src.Bytes);

            while (p.MoveNext())
            {
                var b = p.Current;
                switch (b)
                {
                case 0x30: value = value * 10; break;

                case 0x31: value = value * 10 + 1; break;

                case 0x32: value = value * 10 + 2; break;

                case 0x33: value = value * 10 + 3; break;

                case 0x34: value = value * 10 + 4; break;

                case 0x35: value = value * 10 + 5; break;

                case 0x36: value = value * 10 + 6; break;

                case 0x37: value = value * 10 + 7; break;

                case 0x38: value = value * 10 + 8; break;

                case 0x39: value = value * 10 + 9; break;

                default: throw new ArgumentOutOfRangeException();
                }
            }
            return(value);
        }
        public static bool TrySearchAscii(this Utf8Bytes src, Byte target, int start, out int pos)
        {
            var p = new Utf8Iterator(src.Bytes, start);

            while (p.MoveNext())
            {
                var b = p.Current;
                if (b <= 0x7F)
                {
                    // ascii
                    if (b == target /*'\"'*/)
                    {
                        // closed
                        pos = p.BytePosition;
                        return(true);
                    }
                    else if (b == '\\')
                    {
                        // escaped
                        switch ((char)p.Second)
                        {
                        case '"':     // fall through
                        case '\\':    // fall through
                        case '/':     // fall through
                        case 'b':     // fall through
                        case 'f':     // fall through
                        case 'n':     // fall through
                        case 'r':     // fall through
                        case 't':     // fall through
                                      // skip next
                            p.MoveNext();
                            break;

                        case 'u':     // unicode
                                      // skip next 4
                            p.MoveNext();
                            p.MoveNext();
                            p.MoveNext();
                            p.MoveNext();
                            break;

                        default:
                            // unkonw escape
                            throw new KeyNotFoundException("unknown escape: " + p.Second);
                        }
                    }
                }
            }

            pos = -1;
            return(false);
        }