Example #1
0
 private void OnEncodingDetectionFinished(object sender, EncodingDetectedEventArgs e)
 {
     this.probeWatch.Restart();
     this.RunOnGuiThread(delegate
     {
         this.view.SetLogProgressCustomText(string.Empty);
         this.view.SetFileEncoding(e.ToString());
     });
 }
Example #2
0
        /// <summary>
        /// Event is called by the tokenizer when a content-encoding meta tag is found. We should just always return true.
        /// </summary>
        ///
        /// <param name="sender">
        /// The tokenizer
        /// </param>
        /// <param name="e">
        /// Encoding detected event information.
        /// </param>

        private void tokenizer_EncodingDeclared(object sender, EncodingDetectedEventArgs e)
        {
            Encoding encoding;

            try
            {
                encoding = Encoding.GetEncoding(e.Encoding);
            }
            catch
            {
                // when an invalid encoding is detected just ignore.
                return;
            }


            bool accept = false;

            // only accept new encodings from meta if there has been no encoding identified already

            if (encoding != null &&
                ActiveEncoding == null)
            {
                accept         = true;
                ActiveEncoding = encoding;

                // when CanRead & CanSeek then it means we can and should restart the stream. If outside of 1K
                // then it's illegal, don't actually restart, just change encoding midstream.

                if (!AlreadyReEncoded &&
                    ActiveStreamOffset < preprocessorBlockBytes)
                {
                    ReEncode = ReEncodeAction.ReEncode;
                    accept   = true;
                }
                else
                {
                    ReEncode = ReEncodeAction.ChangeEncoding;
                    accept   = false;
                }
            }
            e.AcceptEncoding = accept;
        }
Example #3
0
		public bool InternalEncodingDeclaration(string internalCharset)
		{
			bool accept = false;
			if (EncodingDeclared != null)
			{
				foreach (var inv in EncodingDeclared.GetInvocationList())
				{
					var args = new EncodingDetectedEventArgs(internalCharset);
					inv.DynamicInvoke(this, args);
					if (args.AcceptEncoding)
						accept = true;
				}
			}

			return accept;
		}