Exemple #1
0
        public ProbingState HandleData(byte[] buffer, int start, int length)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer", Properties.Resources.NullBufferExceptionMessage);
            }
            if (start < 0)
            {
                throw new ArgumentException(Properties.Resources.NegativeStartIndexExceptionMessage, "start");
            }

            // if we are not active, we needn't do any work.
            if (!this.isActive)
            {
                return(this.state);
            }
            // otherwise, we continue, even if we've made up our mind.

            foreach (ICharSetProber prober in this.probers)
            {
                if (!prober.IsActive)
                {
                    continue;
                }

                ProbingState st = prober.HandleData(buffer, start, length);
                if (st == ProbingState.FoundIt)
                {
                    this.bestGuess = prober;
                    this.state     = ProbingState.FoundIt;
                    break;
                }
                else if (st == ProbingState.NotMe)
                {
                    prober.IsActive = false;
                    this.activeNum--;
                    if (this.activeNum <= 0)
                    {
                        this.state    = ProbingState.NotMe;
                        this.isActive = false;
                        break;
                    }
                }
            }

            return(this.state);
        }
Exemple #2
0
        public SBCSGroupProber()
        {
            this.probers.Add(new Win1251CharSetProber());
            this.probers.Add(new Koi8RCharSetProber());
            this.probers.Add(new Latin5CharSetProber());
            this.probers.Add(new MacCyrillicCharSetProber());
            this.probers.Add(new Ibm866CharSetProber());
            this.probers.Add(new Ibm855CharSetProber());

            this.probers.Add(new Latin7CharSetProber());
            this.probers.Add(new Win1253CharSetProber());
            this.probers.Add(new Latin5BulgarianCharSetProber());
            this.probers.Add(new Win1251BulgarianCharSetProber());
            this.probers.Add(new Latin2CharSetProber());
            this.probers.Add(new Win1250CharSetProber());
            this.probers.Add(new TIS620CharSetProber());
            //this.probers.Add(new HebrewGroupProber());

            this.bestGuess = this.probers[0];
            this.activeNum = this.probers.Count;
            this.isActive  = true;
        }