Error() public method

public Error ( CSToolsException e ) : void
e CSToolsException
return void
 /// <exclude/>
 public static Encoding GetEncoding(string enc, ref bool toupper,ErrorHandler erh)
 {
     switch (enc)
     {
         case "": return Encoding.Default; // locale-specific
         case "ASCII": return Encoding.ASCII;
         case "ASCIICAPS": toupper=true; return Encoding.ASCII; // toupper is currently ignored in scripts
         case "UTF7": return Encoding.UTF7;
         case "UTF8": return Encoding.UTF8;
         case "Unicode": return Encoding.Unicode;
         default:
             try
             {
                 return Encoding.GetEncoding(int.Parse(enc)); // codepage
             }
             catch (Exception)
             {
                 erh.Error(new CSToolsException(43,"Warning: Encoding "+enc+" unknown: ignored"));
             }
             break;
     }
     return Encoding.ASCII;
 }
Ejemplo n.º 2
0
        internal ChTest GetTest(string name)
        {
            try {
                object o = Enum.Parse(typeof(UnicodeCategory), name);
                if (o != null)
                {
                    UnicodeCategory cat = (UnicodeCategory)o;
                    UsingCat(cat);
                    return(new ChTest(new CatTest(cat).Test));
                }
            } catch (Exception) {}
            switch (name)
            {
            case "Symbol":
                UsingCat(UnicodeCategory.OtherSymbol);
                UsingCat(UnicodeCategory.ModifierSymbol);
                UsingCat(UnicodeCategory.CurrencySymbol);
                UsingCat(UnicodeCategory.MathSymbol);
                return(new ChTest(CharIsSymbol));

            case "Punctuation":
                UsingCat(UnicodeCategory.OtherPunctuation);
                UsingCat(UnicodeCategory.FinalQuotePunctuation);
                UsingCat(UnicodeCategory.InitialQuotePunctuation);
                UsingCat(UnicodeCategory.ClosePunctuation);
                UsingCat(UnicodeCategory.OpenPunctuation);
                UsingCat(UnicodeCategory.DashPunctuation);
                UsingCat(UnicodeCategory.ConnectorPunctuation);
                return(new ChTest(Char.IsPunctuation));

            /*			case "PrivateUse":
             *                              UsingCat(UnicodeCategory.PrivateUse);
             *                              return new ChTest(Char.IsPrivateUse); */
            case "Separator":
                UsingCat(UnicodeCategory.ParagraphSeparator);
                UsingCat(UnicodeCategory.LineSeparator);
                UsingCat(UnicodeCategory.SpaceSeparator);
                return(new ChTest(CharIsSeparator));

            case "WhiteSpace":
                UsingCat(UnicodeCategory.Control);
                UsingCat(UnicodeCategory.ParagraphSeparator);
                UsingCat(UnicodeCategory.LineSeparator);
                UsingCat(UnicodeCategory.SpaceSeparator);
                return(new ChTest(Char.IsWhiteSpace));

            case "Number":
                UsingCat(UnicodeCategory.OtherNumber);
                UsingCat(UnicodeCategory.LetterNumber);
                UsingCat(UnicodeCategory.DecimalDigitNumber);
                return(new ChTest(Char.IsNumber));

            case "Digit":
                UsingCat(UnicodeCategory.DecimalDigitNumber);
                return(new ChTest(Char.IsDigit));

            /*			case "Mark":
             *                              UsingCat(UnicodeCategory.EnclosingMark);
             *                              UsingCat(UnicodeCategory.SpacingCombiningMark);
             *                              UsingCat(UnicodeCategory.NonSpacingMark);
             *                              return new ChTest(Char.IsMark); */
            case "Letter":
                UsingCat(UnicodeCategory.OtherLetter);
                UsingCat(UnicodeCategory.ModifierLetter);
                UsingCat(UnicodeCategory.TitlecaseLetter);
                UsingCat(UnicodeCategory.LowercaseLetter);
                UsingCat(UnicodeCategory.UppercaseLetter);
                return(new ChTest(Char.IsLetter));

            case "Lower":
                UsingCat(UnicodeCategory.LowercaseLetter);
                return(new ChTest(Char.IsLower));

            case "Upper":
                UsingCat(UnicodeCategory.UppercaseLetter);
                return(new ChTest(Char.IsUpper));

            case "EOF":
                UsingCat(UnicodeCategory.OtherNotAssigned);
                UsingChar((char)0xFFFF);
                usingEOF = true;
                return(new ChTest(testEOF));

            default:
                erh.Error(new CSToolsException(24, "No such Charset " + name));
                break;
            }
            return(new ChTest(Char.IsControl));            // not reached
        }