コード例 #1
0
ファイル: VCFWriter.cs プロジェクト: w3he/Bio.VCF
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public VCFWriter(final File location, final OutputStream output, final net.sf.samtools.SAMSequenceDictionary refDict, final boolean enableOnTheFlyIndexing, boolean doNotWriteGenotypes, final boolean allowMissingFieldsInHeader)
		public VCFWriter(File location, OutputStream output, SAMSequenceDictionary refDict, bool enableOnTheFlyIndexing, bool doNotWriteGenotypes, bool allowMissingFieldsInHeader) : base(writerName(location, output), location, output, refDict, enableOnTheFlyIndexing)
		{
			this.doNotWriteGenotypes = doNotWriteGenotypes;
			this.allowMissingFieldsInHeader = allowMissingFieldsInHeader;
			this.charset = Charset.forName("ISO-8859-1");
			this.writer = new OutputStreamWriter(lineBuffer, charset);
		}
コード例 #2
0
ファイル: TagForm.cs プロジェクト: bzure/BSA.Net
        /// <summary>Assigns all needed attributes to the tag</summary>
        /// <returns>This instance downcasted to base class</returns>
        public virtual IndexedTag attr(
            string action = null,
            Method? method = null,
            MimeType enctype = null,
            Target target = null,
            string onsubmit = null,
            string onreset = null,
            MimeType[] accept = null,
            Charset[] acceptcharset = null,
            string id = null,
            string name = null,
            string @class = null,
            string style = null,
            string title = null,
            LangCode lang = null,
            string xmllang = null,
            Dir? dir = null,
            string onclick = null,
            string ondblclick = null,
            string onmousedown = null,
            string onmouseup = null,
            string onmouseover = null,
            string onmousemove = null,
            string onmouseout = null,
            string onkeypress = null,
            string onkeydown = null,
            string onkeyup = null
        )
        {
            Action = action;
            Method = method;
            EncType = enctype;
            Target = target;
            OnSubmit = onsubmit;
            OnReset = onreset;
            Accept = accept;
            AcceptCharset = acceptcharset;
            Id = id;
            Name = name;
            Class = @class;
            Style = style;
            Title = title;
            Lang = lang;
            XmlLang = xmllang;
            Dir = dir;
            OnClick = onclick;
            OnDblClick = ondblclick;
            OnMouseDown = onmousedown;
            OnMouseUp = onmouseup;
            OnMouseOver = onmouseover;
            OnMouseMove = onmousemove;
            OnMouseOut = onmouseout;
            OnKeyPress = onkeypress;
            OnKeyDown = onkeydown;
            OnKeyUp = onkeyup;

            return this;
        }
コード例 #3
0
ファイル: TagLink.cs プロジェクト: bzure/BSA.Net
        /// <summary>Assigns all needed attributes to the tag</summary>
        /// <returns>This instance downcasted to base class</returns>
        public virtual IndexedTag attr(
            Charset charset = null,
            string href = null,
            LangCode hreflang = null,
            Target target = null,
            MimeType type = null,
            LinkType? rel = null,
            LinkType? rev = null,
            Media? media = null,
            string id = null,
            string @class = null,
            string style = null,
            string title = null,
            LangCode lang = null,
            string xmllang = null,
            Dir? dir = null,
            string onclick = null,
            string ondblclick = null,
            string onmousedown = null,
            string onmouseup = null,
            string onmouseover = null,
            string onmousemove = null,
            string onmouseout = null,
            string onkeypress = null,
            string onkeydown = null,
            string onkeyup = null
        )
        {
            Charset = charset;
            Href = href;
            HrefLang = hreflang;
            Target = target;
            Type = type;
            Rel = rel;
            Rev = rev;
            Media = media;
            Id = id;
            Class = @class;
            Style = style;
            Title = title;
            Lang = lang;
            XmlLang = xmllang;
            Dir = dir;
            OnClick = onclick;
            OnDblClick = ondblclick;
            OnMouseDown = onmousedown;
            OnMouseUp = onmouseup;
            OnMouseOver = onmouseover;
            OnMouseMove = onmousemove;
            OnMouseOut = onmouseout;
            OnKeyPress = onkeypress;
            OnKeyDown = onkeydown;
            OnKeyUp = onkeyup;

            return this;
        }
コード例 #4
0
        public Filesystem3ToFuseFSAdapter(Filesystem3 fs3, Charset cs, ILog log)
        {
            this.fs3 = fs3;

            // XattrSupport is optional
            if (fs3 is XattrSupport)
                xattrSupport = (XattrSupport)fs3;

            this.cs = cs;
            this.log = log;
        }
コード例 #5
0
ファイル: TagScript.cs プロジェクト: bzure/BSA.Net
        /// <summary>Assigns all needed attributes to the tag</summary>
        /// <returns>This instance downcasted to base class</returns>
        public virtual IndexedTag attr(
            Charset charset = null,
            MimeType type = null,
            string src = null,
            Defer? defer = null,
            string xmlspace = null
        )
        {
            Charset = charset;
            Type = type;
            Src = src;
            Defer = defer;
            XmlSpace = xmlspace;

            return this;
        }
コード例 #6
0
        public virtual void Detach()
        {
            lock (this.SyncObject)
            {
                if (this.TransactionCount > 0)
                {
                    throw new IscException(IscCodes.isc_open_trans, this.TransactionCount);
                }

                try
                {
                    if (this.handle != 0)
                    {
                        this.Write(IscCodes.op_detach);
                        this.Write(this.handle);
                    }
                    this.Write(IscCodes.op_disconnect);
                    this.Flush();

                    // Close the Event Manager
                    this.CloseEventManager();

                    // Disconnect
                    this.CloseConnection();

                    // Close Input and Output streams
                    if (this.inputStream != null)
                    {
                        this.inputStream.Close();
                    }
                    if (this.outputStream != null)
                    {
                        this.outputStream.Close();
                    }

                    // Clear members
                    this.transactionCount = 0;
                    this.handle           = 0;
                    this.dialect          = 0;
                    this.packetSize       = 0;
                    this.operation        = 0;
                    this.outputStream     = null;
                    this.inputStream      = null;
                    this.charset          = null;
                    this.connection       = null;
                    this.serverVersion    = null;
                }
                catch (IOException)
                {
                    try
                    {
                        this.CloseConnection();
                    }
                    catch (IOException)
                    {
                        throw new IscException(IscCodes.isc_network_error);
                    }

                    throw new IscException(IscCodes.isc_network_error);
                }
            }
        }
コード例 #7
0
 string GetAsciiSpecialCharacters( Charset charset )
 {
     if ( charset.HasFlag ( Charset.AsciiSpecialChars ) )
         return "`-=\\][;',./~!@#$%^&*()_+{}|:\"<>?";
     else return "";
 }
コード例 #8
0
 private void FixDocumentCharset(ITextDocument document, Charset charset)
 {
     if (charset == Charset.Latin1)
         document.Encoding = Encoding.GetEncoding("ISO-8859-1");
     else if (charset == Charset.UTF8)
         document.Encoding = new UTF8Encoding(false);
     else if (charset == Charset.UTF8BOM)
         document.Encoding = new UTF8Encoding(true);
     else if (charset == Charset.UTF16LE)
         document.Encoding = Encoding.Unicode;
     else if (charset == Charset.UTF16BE)
         document.Encoding = Encoding.BigEndianUnicode;
 }
コード例 #9
0
        public static void CreateDatabase(string connectionString, int pageSize = 4096, bool forcedWrites = true, bool overwrite = false)
        {
            FbConnectionString options = new FbConnectionString(connectionString);

            options.Validate();

            try
            {
                // DPB configuration
                DatabaseParameterBuffer dpb = new DatabaseParameterBuffer();

                // Dpb version
                dpb.Append(IscCodes.isc_dpb_version1);

                // Dummy packet	interval
                dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 });

                // User	name
                dpb.Append(IscCodes.isc_dpb_user_name, options.UserID);

                // User	password
                dpb.Append(IscCodes.isc_dpb_password, options.Password);

                // Database	dialect
                dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { options.Dialect, 0, 0, 0 });

                // Character set
                if (options.Charset.Length > 0)
                {
                    Charset charset = Charset.GetCharset(options.Charset);

                    if (charset == null)
                    {
                        throw new ArgumentException("Character set is not valid.");
                    }
                    else
                    {
                        dpb.Append(IscCodes.isc_dpb_set_db_charset, charset.Name);
                    }
                }

                // Forced writes
                dpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0));

                // Database overwrite
                dpb.Append(IscCodes.isc_dpb_overwrite, (overwrite ? 1 : 0));

                // Page	Size
                if (pageSize > 0)
                {
                    dpb.Append(IscCodes.isc_dpb_page_size, pageSize);
                }

                // Create the new database
                FbConnectionInternal db = new FbConnectionInternal(options);
                db.CreateDatabase(dpb);
            }
            catch (IscException ex)
            {
                throw new FbException(ex.Message, ex);
            }
        }
コード例 #10
0
ファイル: Charset.cs プロジェクト: Rhombulus/Mime
 public static bool TryGetCharset(int codePage, out Charset charset)
 {
     return CultureCharsetDatabase.Data.CodePageToCharset.TryGetValue(codePage, out charset);
 }
コード例 #11
0
 public FileToStringSampleStream(ObjectStream <Jfile> samples, Charset encoding)
     : base(samples)
 {
     this.encoding = encoding;
 }
コード例 #12
0
 public InputStreamReader(InputStream.InputStream stream, Charset charset)
     : base(stream)
 {
     _charset = charset;
 }
コード例 #13
0
 string GetNumbers( Charset charset )
 {
     if ( charset.HasFlag ( Charset.Numbers ) )
         return "0123456789";
     else return "";
 }
コード例 #14
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

            if (Property.Expression != null)
            {
                targetCommand.AddParameter("Property", Property.Get(context));
            }

            if (Body.Expression != null)
            {
                targetCommand.AddParameter("Body", Body.Get(context));
            }

            if (Head.Expression != null)
            {
                targetCommand.AddParameter("Head", Head.Get(context));
            }

            if (Title.Expression != null)
            {
                targetCommand.AddParameter("Title", Title.Get(context));
            }

            if (As.Expression != null)
            {
                targetCommand.AddParameter("As", As.Get(context));
            }

            if (CssUri.Expression != null)
            {
                targetCommand.AddParameter("CssUri", CssUri.Get(context));
            }

            if (Fragment.Expression != null)
            {
                targetCommand.AddParameter("Fragment", Fragment.Get(context));
            }

            if (PostContent.Expression != null)
            {
                targetCommand.AddParameter("PostContent", PostContent.Get(context));
            }

            if (PreContent.Expression != null)
            {
                targetCommand.AddParameter("PreContent", PreContent.Get(context));
            }

            if (Meta.Expression != null)
            {
                targetCommand.AddParameter("Meta", Meta.Get(context));
            }

            if (Charset.Expression != null)
            {
                targetCommand.AddParameter("Charset", Charset.Get(context));
            }

            if (Transitional.Expression != null)
            {
                targetCommand.AddParameter("Transitional", Transitional.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
コード例 #15
0
 public InputStreamReader(FileInputStream stream, string encoding = null)
     : base(stream)
 {
     _charset = !string.IsNullOrEmpty(encoding) ? Charset.forName(encoding) : Charset.defaultCharset();
 }
コード例 #16
0
        public static IscException ParseStatusVector(IntPtr[] statusVector, Charset charset)
        {
            IscException exception = null;
            bool         eof       = false;

            for (int i = 0; i < statusVector.Length;)
            {
                IntPtr arg = statusVector[i++];

                switch (arg.ToInt32())
                {
                case IscCodes.isc_arg_gds:
                    IntPtr er = statusVector[i++];
                    if (er != IntPtr.Zero)
                    {
                        if (exception == null)
                        {
                            exception = new IscException();
                        }
                        exception.Errors.Add(new IscError(arg.ToInt32(), er.ToInt32()));
                    }
                    break;

                case IscCodes.isc_arg_end:
                    if (exception != null && exception.Errors.Count != 0)
                    {
                        exception.BuildExceptionData();
                    }
                    eof = true;
                    break;

                case IscCodes.isc_arg_interpreted:
                case IscCodes.isc_arg_string:
                {
                    IntPtr ptr       = statusVector[i++];
                    string s         = Marshal.PtrToStringAnsi(ptr);
                    string arg_value = charset.GetString(
                        System.Text.Encoding.Default.GetBytes(s));

                    exception.Errors.Add(new IscError(arg.ToInt32(), arg_value));
                }
                break;

                case IscCodes.isc_arg_cstring:
                {
                    i++;

                    IntPtr ptr       = statusVector[i++];
                    string s         = Marshal.PtrToStringAnsi(ptr);
                    string arg_value = charset.GetString(
                        System.Text.Encoding.Default.GetBytes(s));

                    exception.Errors.Add(new IscError(arg.ToInt32(), arg_value));
                }
                break;

                case IscCodes.isc_arg_win32:
                case IscCodes.isc_arg_number:
                    exception.Errors.Add(new IscError(arg.ToInt32(), statusVector[i++].ToInt32()));
                    break;

                default:
                    IntPtr e = statusVector[i++];
                    if (e != IntPtr.Zero)
                    {
                        if (exception == null)
                        {
                            exception = new IscException();
                        }
                        exception.Errors.Add(new IscError(arg.ToInt32(), e.ToInt32()));
                    }
                    break;
                }

                if (eof)
                {
                    break;
                }
            }

            return(exception);
        }
コード例 #17
0
        private void Decode()
        {
            if (_raw == null)
            {
                return;
            }

            int pos = 0;

            ByteArrayExtensions.ParsedLine res = _raw.ReadLine(pos);
            if (res.Buffer == null || !res.Buffer.StartsWith("tree ".getBytes()))
            {
                throw new CorruptObjectException(CommitId, "no tree");
            }

            bool skip;

            do
            {
                skip = false;

                res = _raw.ReadLine(res.NextIndex);

                if ((res.Buffer == null) || !res.Buffer.StartsWith("parent ".getBytes()))
                {
                    skip = true;
                }
            } while (!skip);

            const string authorPrefix = "author ";

            if (res.Buffer == null || !res.Buffer.StartsWith(authorPrefix.getBytes()))
            {
                throw new CorruptObjectException(CommitId, "no author");
            }

            byte[] rawAuthor = ExtractTrailingBytes(res.Buffer, authorPrefix);

            res = _raw.ReadLine(res.NextIndex);

            const string committerPrefix = "committer ";

            if (res.Buffer == null || !res.Buffer.StartsWith(committerPrefix.getBytes()))
            {
                throw new CorruptObjectException(CommitId, "no committer");
            }

            byte[] rawCommitter = ExtractTrailingBytes(res.Buffer, committerPrefix);

            res = _raw.ReadLine(res.NextIndex);

            const string mergetagPrefix = "mergetag ";

            if (res.Buffer != null && res.Buffer.StartsWith(mergetagPrefix.getBytes()))
            {
                byte[] rawMergetag = ExtractTrailingBytes(res.Buffer, mergetagPrefix);
                do
                {
                    res = _raw.ReadLine(res.NextIndex);
                }while (res.NextIndex < _raw.Length && res.Buffer != null && res.Buffer.Length > 0 && res.Buffer[0] == ' ');
            }
            else if (res.Buffer == null || res.Buffer.Length != 0)
            {
                throw new CorruptObjectException(CommitId, "malformed header:" + new ASCIIEncoding().GetString(res.Buffer ?? new byte[0]));
            }
            const string encodingPrefix = "encoding ";

            if (res.Buffer != null && res.Buffer.StartsWith(encodingPrefix.getBytes()))
            {
                byte[] rawEncoding = ExtractTrailingBytes(res.Buffer, encodingPrefix);
                Encoding = Charset.forName(new ASCIIEncoding().GetString(rawEncoding));
            }
            else if (res.Buffer == null || res.Buffer.Length != 0)
            {
                throw new CorruptObjectException(CommitId, "malformed header:" + new ASCIIEncoding().GetString(res.Buffer ?? new byte[0]));
            }

            pos = res.NextIndex;

            var readBuf = new byte[_raw.Length - pos];

            Array.Copy(_raw, pos, readBuf, 0, _raw.Length - pos);
            int msgstart = readBuf.Length != 0 ? (readBuf[0] == '\n' ? 1 : 0) : 0;

            // If encoding is not specified, the default for commit is UTF-8
            if (Encoding == null)
            {
                Encoding = Constants.CHARSET;
            }

            // TODO: this isn't reliable so we need to guess the encoding from the actual content
            Author    = new PersonIdent(Encoding.GetString(rawAuthor));
            Committer = new PersonIdent(Encoding.GetString(rawCommitter));
            Message   = Encoding.GetString(readBuf, msgstart, readBuf.Length - msgstart);

            _raw = null;
        }
コード例 #18
0
ファイル: Encoding.cs プロジェクト: slagusev/api
 /// <summary>
 /// Default ctor
 /// </summary>
 internal Encoding(Charset charSet)
 {
     this.charSet = charSet;
 }
コード例 #19
0
 string GetCompletionHangulCharacters( Charset charset )
 {
     if ( charset.HasFlag ( Charset.Hangul ) )
     {
         StringBuilder stringBuilder = new StringBuilder ();
         for ( int i = 0xAC00; i <= 0xD7AF; i++ )
             stringBuilder.Append ( ( char ) i );
         return stringBuilder.ToString ();
     }
     else return "";
 }
コード例 #20
0
 public InputStreamReader(InputStream.InputStream stream)
     : base(stream)
 {
     _charset = Charset.forName("UTF-8");
 }
コード例 #21
0
 string GetHirakanaKatakana( Charset charset )
 {
     if ( charset.HasFlag ( Charset.JapChars ) )
     {
         StringBuilder stringBuilder = new StringBuilder ();
         for ( int i = 0x3040; i <= 0x309F; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x30A0; i <= 0x30FF; i++ )
             stringBuilder.Append ( ( char ) i );
         return stringBuilder.ToString ();
     }
     else return "";
 }
コード例 #22
0
        public BodyCharsetDetectionStream(Stream outputStream, BodyCharsetDetectionStream.DetectCharsetCallback callback, ICoreItem coreItem, BodyStreamFormat format, Charset contentCharset, Charset userCharset, BodyCharsetFlags charsetFlags, string extraData, bool trustHtmlMetaTag) : base(StreamBase.Capabilities.Writable)
        {
            this.outputStream = outputStream;
            this.callback     = callback;
            this.coreItem     = coreItem;
            this.userCharset  = userCharset;
            this.charsetFlags = charsetFlags;
            Charset charset;

            this.isDetectingCharset = !this.coreItem.CharsetDetector.IsItemCharsetKnownWithoutDetection(charsetFlags, userCharset, out charset);
            if (this.isDetectingCharset)
            {
                this.CreateDetectionStream(format, contentCharset, extraData, trustHtmlMetaTag);
                return;
            }
            this.CalculateCharset();
        }
コード例 #23
0
ファイル: OcrKing.cs プロジェクト: nylyy0325/OcrKing
 /// <summary>
 /// Initializes a new instance of the <see cref="OcrKing"/> class.
 /// </summary>
 /// <param name="apiKey">
 /// The api key.
 /// </param>
 public OcrKing(string apiKey)
 {
     this.ApiKey = apiKey;
     this.Language = Language.Eng;
     this.charset = Charset.DEFAULT;
     this.service = Service.OcrKingForCaptcha;
     this.client = new HttpClient(ApiUrl) { Referer = Referer };
 }
コード例 #24
0
 public string ReadString(Charset charset)
 {
     return(this.inputStream.ReadString(charset));
 }
コード例 #25
0
 /**
  * Constructs a new <code>CharsetDecoder</code> using the given
  * <code>Charset</code>, average number and maximum number of characters
  * created by this decoder for one input byte, and the default replacement
  * string "\uFFFD".
  *
  * @param charset
  *            the <code>Charset</code> to be used by this decoder.
  * @param averageCharsPerByte
  *            the average number of characters created by this decoder for
  *            one input byte, must be positive.
  * @param maxCharsPerByte
  *            the maximum number of characters created by this decoder for
  *            one input byte, must be positive.
  * @throws IllegalArgumentException
  *             if <code>averageCharsPerByte</code> or
  *             <code>maxCharsPerByte</code> is negative.
  */
 protected CharsetDecoder(Charset charset, float averageCharsPerByte,
         float maxCharsPerByte)
 {
     if (averageCharsPerByte <= 0 || maxCharsPerByte <= 0) {
         // niochar.00=Characters number for one byte must be positive.
         throw new java.lang.IllegalArgumentException("Characters number for one byte must be positive."); //$NON-NLS-1$
     }
     if (averageCharsPerByte > maxCharsPerByte) {
         // niochar.01=averageCharsPerByte is greater than maxCharsPerByte
         throw new java.lang.IllegalArgumentException("averageCharsPerByte is greater than maxCharsPerByte"); //$NON-NLS-1$
     }
     averChars = averageCharsPerByte;
     maxChars = maxCharsPerByte;
     cs = charset;
     status = INIT;
     malformAction = CodingErrorAction.REPORT;
     unmapAction = CodingErrorAction.REPORT;
     replace = "\ufffd"; //$NON-NLS-1$
 }
コード例 #26
0
ファイル: Text.cs プロジェクト: Foohy/OlegEngine
 public void SetCharset(Charset ch)
 {
     this.charset = ch;
     this.textMesh.mat = ch.CharsetMaterial;
 }
コード例 #27
0
ファイル: RegexTests.cs プロジェクト: TheFellow/RegexLib
        public static void test_negated_nested_charset()
        {
            var cset3 = new Charset();
            cset3.Include('c');

            var cset2 = new Charset();
            cset2.Include('b', 'd');
            cset2.Exclude(cset3);

            var cset1 = new Charset(false);
            cset1.Include('a', 'e');
            cset1.Exclude(cset2);

            // ([^a-e-[b-d-[c]]])
            ExecTest(new Context("a"), cset1);  // No
            ExecTest(new Context("b"), cset1);  // Yes
            ExecTest(new Context("c"), cset1);  // No
            ExecTest(new Context("d"), cset1);  // Yes
            ExecTest(new Context("e"), cset1);  // No
        }
コード例 #28
0
ファイル: Utils.cs プロジェクト: Cinegy/TsAnalyser
        public static void remap_g0_charset(byte c, Charset primaryCharset)
        {
            if (c == primaryCharset.Current) return;

            var m = G0LatinNationalSubsetsMap[c];
            if (m == 0xff)
            {
                //not supported
            }
            else
            {
                for (byte j = 0; j < 13; j++) G0[(int)TtxLanguages.Latin][G0LatinNationalSubsetsPositions[j]] = G0LatinNationalSubsets[m].Characters[j];
                primaryCharset.Current = c;
            }
        }
コード例 #29
0
        private void read()
        {
            readHeader();
            if (header.sig != VSMX_SIGNATURE)
            {
                Console.WriteLine(string.Format("Invalid VSMX signature 0x{0:X8}", header.sig));
                return;
            }
            if (header.ver != VSMX_VERSION)
            {
                Console.WriteLine(string.Format("Invalid VSMX version 0x{0:X8}", header.ver));
                return;
            }

            if (header.codeOffset > header.size())
            {
                Console.WriteLine(string.Format("VSMX: skipping range after header: 0x{0:X}-0x{1:X}", header.size(), header.codeOffset));
                seek(header.codeOffset);
            }

            if ((header.codeLength % VSMXGroup.SIZE_OF) != 0)
            {
                Console.WriteLine(string.Format("VSMX: code Length is not aligned to 8 bytes: 0x{0:X}", header.codeLength));
            }

            mem       = new VSMXMem();
            mem.codes = new VSMXGroup[header.codeLength / VSMXGroup.SIZE_OF];
            for (int i = 0; i < mem.codes.Length; i++)
            {
                mem.codes[i]       = new VSMXGroup();
                mem.codes[i].id    = read32();
                mem.codes[i].value = read32();
            }

            mem.texts      = readStrings(header.textOffset, header.textLength, header.textEntries, Charset.forName("UTF-16LE"), 2);
            mem.properties = readStrings(header.propOffset, header.propLength, header.propEntries, Charset.forName("UTF-16LE"), 2);
            mem.names      = readStrings(header.namesOffset, header.namesLength, header.namesEntries, Charset.forName("ISO-8859-1"), 1);

            //if (log.DebugEnabled)
            {
                debug();
            }
        }
コード例 #30
0
 public string ReadString(Charset charset, int length)
 {
     return(this.inputStream.ReadString(charset, length));
 }
コード例 #31
0
        private static IDatabase CreateManagedDatabase(ConnectionString options)
        {
            var connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.PacketSize, Charset.GetCharset(options.Charset), options.Compression, FbWireCryptToWireCryptOption(options.WireCrypt), options.ConnectionTimeout);

            connection.Connect();
            connection.Identify(options.Database);
            switch (connection.ProtocolVersion)
            {
            case IscCodes.PROTOCOL_VERSION13:
                return(new Client.Managed.Version13.GdsDatabase(connection));

            case IscCodes.PROTOCOL_VERSION12:
                return(new Client.Managed.Version12.GdsDatabase(connection));

            case IscCodes.PROTOCOL_VERSION11:
                return(new Client.Managed.Version11.GdsDatabase(connection));

            case IscCodes.PROTOCOL_VERSION10:
                return(new Client.Managed.Version10.GdsDatabase(connection));

            default:
                throw UnsupportedProtocolException();
            }
        }
コード例 #32
0
        private bool BuildParameterDescriptor(Descriptor descriptor, FbParameter parameter, int index)
        {
            if (!parameter.IsTypeSet)
            {
                return(false);
            }

            FbDbType type    = parameter.FbDbType;
            Charset  charset = _connection.InnerConnection.Database.Charset;

            // Check the parameter character set
            if (parameter.Charset == FbCharset.Octets && !(parameter.InternalValue is byte[]))
            {
                throw new InvalidOperationException("Value for char octets fields should be a byte array");
            }
            else if (type == FbDbType.Guid)
            {
                charset = Charset.GetCharset(Charset.Octets);
            }
            else if (parameter.Charset != FbCharset.Default)
            {
                charset = Charset.GetCharset((int)parameter.Charset);
            }

            // Set parameter Data Type
            descriptor[index].DataType = (short)TypeHelper.GetSqlTypeFromDbDataType(TypeHelper.GetDbDataTypeFromFbDbType(type), parameter.IsNullable);

            // Set parameter Sub Type
            switch (type)
            {
            case FbDbType.Binary:
                descriptor[index].SubType = 0;
                break;

            case FbDbType.Text:
                descriptor[index].SubType = 1;
                break;

            case FbDbType.Guid:
                descriptor[index].SubType = (short)charset.Identifier;
                break;

            case FbDbType.Char:
            case FbDbType.VarChar:
                descriptor[index].SubType = (short)charset.Identifier;
                if (charset.IsOctetsCharset)
                {
                    descriptor[index].Length = (short)parameter.Size;
                }
                else if (parameter.HasSize)
                {
                    short len = (short)(parameter.Size * charset.BytesPerCharacter);
                    descriptor[index].Length = len;
                }
                break;
            }

            // Set parameter length
            if (descriptor[index].Length == 0)
            {
                descriptor[index].Length = TypeHelper.GetSize((DbDataType)type) ?? 0;
            }

            // Verify parameter
            if (descriptor[index].SqlType == 0 || descriptor[index].Length == 0)
            {
                return(false);
            }

            return(true);
        }
コード例 #33
0
ファイル: Text.cs プロジェクト: Foohy/OlegEngine
        public static void ConstructVertexArray(Charset ch, string str, out Vertex[] verts, out int[] elements )
        {
            ushort CharX;
            ushort CharY;
            ushort Width;
            ushort Height;
            ushort OffsetX;
            ushort OffsetY;
            int CurX = 0;

            //vert stuff
            verts = new Vertex[str.Length * 4];
            elements = new int[str.Length * 4];

            for (int i = 0; i < str.Length; i++)
            {
                char curChar = str[i];
                if (curChar > ch.Chars.Length) continue;

                CharX = ch.Chars[curChar].x;
                CharY = ch.Chars[curChar].y;
                Width = ch.Chars[curChar].Width;
                Height = ch.Chars[curChar].Height;
                OffsetX = ch.Chars[curChar].XOffset;
                OffsetY = ch.Chars[curChar].YOffset;

                //upper left
                verts[i * 4].UV.X = (float)CharX / (float)ch.Width;
                verts[i * 4].UV.Y = (float)CharY / (float)ch.Height;
                verts[i * 4].Position.X = (float)CurX + OffsetX;
                verts[i * 4].Position.Y = (float)OffsetY;
                verts[i * 4].Color = (Vector3h)Vector3.One;
                elements[i*4] = i*4;

                //upper right
                verts[i * 4 + 1].UV.X = (float)(CharX + Width) / (float)ch.Width;
                verts[i * 4 + 1].UV.Y = (float)CharY / (float)ch.Height;
                verts[i * 4 + 1].Position.X = (float)Width + CurX + OffsetX;
                verts[i * 4 + 1].Position.Y = (float)OffsetY;
                verts[i * 4 + 1].Color = (Vector3h)Vector3.One;
                elements[i*4 + 1] = i*4 + 1;

                //lower right
                verts[i * 4 + 2].UV.X = (float)(CharX + Width) / (float)ch.Width;
                verts[i * 4 + 2].UV.Y = (float)(CharY + Height) / (float)ch.Height;
                verts[i * 4 + 2].Position.X = (float)Width + CurX + OffsetX;
                verts[i * 4 + 2].Position.Y = (float)Height + OffsetY;
                verts[i * 4 + 2].Color = (Vector3h)Vector3.One;
                elements[i*4 + 2] = i*4 + 2;

                //lower left
                verts[i * 4 + 3].UV.X = (float)CharX / (float)ch.Width;
                verts[i * 4 + 3].UV.Y = (float)(CharY + Height) / (float)ch.Height;
                verts[i * 4 + 3].Position.X = (float)CurX + OffsetX;
                verts[i * 4 + 3].Position.Y = (float)Height + OffsetY;
                verts[i * 4 + 3].Color = (Vector3h)Vector3.One;
                elements[i*4 + 3] = i*4 + 3;

                CurX += ch.Chars[curChar].XAdvance;
            }
        }
コード例 #34
0
 public GdsConnection(string userID, string password, string dataSource, int portNumber, int packetSize, Charset characterSet, bool compression)
 {
     _userID       = userID;
     _password     = password;
     _dataSource   = dataSource;
     _portNumber   = portNumber;
     _packetSize   = packetSize;
     _characterSet = characterSet;
     _compression  = compression;
 }
コード例 #35
0
ファイル: EncodingHelper.cs プロジェクト: springcomp/TextPad
        /// <summary>
        /// Return a <see cref="Encoding" /> object associated with the specified <see cref="Charset" />.
        /// The Encoding object is associated with custom implementations for the
        /// <see cref"EncoderFallback" /> and <see cref"DecoderFallback" /> objects so
        /// that it is possible to determine whether any replacement occurred during decoding.
        /// </summary>
        /// <param name="charset"></param>
        /// <returns></returns>
        public static Encoding GetEncoding(Charset charset)
        {
            var decoderFallback = new CustomReplacementDecoderFallback();
            var encoderFallback = EncoderFallback.ReplacementFallback;

            switch (charset)
            {
                case Charset.Greece:
                    {
                        var encoding = Windows1253Encoding.Create(
                            encoderFallback
                            , decoderFallback)
                            ;
                        return encoding;
                    }

                case Charset.CentralEasternEurope:
                    {
                        var encoding = Windows1250Encoding.Create(
                            encoderFallback
                            , decoderFallback)
                            ;
                        return encoding;
                    }

                case Charset.WesternEurope:
                    {
                        var encoding = Windows1252Encoding.Create(
                            encoderFallback
                            , decoderFallback)
                            ;
                        return encoding;
                    }

                case Charset.UnicodeBe:
                    {
                        var cp = Encoding.BigEndianUnicode.CodePage;
                        var encoding = Encoding.GetEncoding(cp
                            , EncoderFallback.ReplacementFallback
                            , decoderFallback
                            );
                        return encoding;
                    }

                case Charset.UnicodeLe:
                    {
                        var cp = Encoding.Unicode.CodePage;
                        var encoding = Encoding.GetEncoding(cp
                            , EncoderFallback.ReplacementFallback
                            , decoderFallback
                            );
                        return encoding;
                    }

                case Charset.UTF8:
                default:
                    {
                        var cp = Encoding.UTF8.CodePage;
                        var encoding = Encoding.GetEncoding(cp
                            , EncoderFallback.ReplacementFallback
                            , decoderFallback
                            );
                        return encoding;
                    }
            }
        }
コード例 #36
0
        private void verifyPayment(Payment payment)
        {
            JSONObject jsonObject = new JSONObject();

            try
            {
                jsonObject.Put("payload", payment.Payload);
            }
            catch (JSONException e)
            {
                Toast.MakeText(this, "Failed to verify payment.", ToastLength.Long).Show();
                return;
            }
            String verifyString = jsonObject.ToString();

            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Content-Type", "application/json; charset=UTF-8");
            headers.Add(merchantApiHeaderKeyForApiSecretKey, merchantApiSecretKey);
            String resultString = "";


            AsyncHttpClient.Post(merchantServerUrl + VERIFY, headers, verifyString, new HttpResponseCallback
            {
                Success = (response) =>
                {
                    try
                    {
                        JSONObject jsonVerifyResponse = new JSONObject((string)new Java.Lang.String(response, Charset.ForName("UTF-8")));
                        String authResponse           = jsonVerifyResponse.GetString("authResponse");
                        if (authResponse.Equals(payment.GetPaymentStatus().ToString()))
                        {
                            resultString = "Payment is " + payment.GetPaymentStatus().ToString().ToLower() + " and verified.";
                        }
                        else
                        {
                            resultString = "Failed to verify payment.";
                        }
                    }
                    catch (JSONException e)
                    {
                        resultString = "Failed to verify payment.";
                    }
                    Toast.MakeText(this, resultString, ToastLength.Long).Show();
                },

                Failure = (e) =>
                {
                    Toast.MakeText(this, resultString, ToastLength.Long).Show();
                }
            });
        }
コード例 #37
0
ファイル: _DigestClient.cs プロジェクト: REALTOBIZ/mono
        private static string CharsetEncode(string rawString, Charset charset) {
#if TRAVE
            GlobalLog.Print("HttpDigest::CharsetEncode() encoding rawString:[" + rawString + "] Chars(rawString):[" + Chars(rawString) + "] charset:[" + charset + "]");
#endif // #if TRAVE
            if (charset==Charset.UTF8 || charset==Charset.ANSI) {
                byte[] bytes = charset==Charset.UTF8 ? Encoding.UTF8.GetBytes(rawString) : Encoding.Default.GetBytes(rawString);
                // the following code is the same as:
                // rawString = Encoding.Default.GetString(bytes);
                // but it's faster.
                char[] chars = new char[bytes.Length];
                bytes.CopyTo(chars, 0);
                rawString = new string(chars);
            }
#if TRAVE
            GlobalLog.Print("HttpDigest::CharsetEncode() encoded rawString:[" + rawString + "] Chars(rawString):[" + Chars(rawString) + "] charset:[" + charset + "]");
#endif // #if TRAVE
            return rawString;
        }
コード例 #38
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            Button   startTest = FindViewById <Button>(Resource.Id.startTest);
            ListView listView  = FindViewById <ListView>(Resource.Id.listView);

            startTest.Click += delegate
            {
                ArrayAdapter <string> adapter = new ArrayAdapter <string>(
                    this,
                    Android.Resource.Layout.SimpleListItem1,
                    Android.Resource.Id.Text1);
                listView.Adapter = adapter;

                OkHttpClient client = new OkHttpClient();

                // Create request for remote resource.
                Request request = new Request.Builder()
                                  .Url(Endpoint)
                                  .Build();

                // Execute the request and retrieve the response.
                WebSocketCall     call     = WebSocketCall.Create(client, request);
                WebSocketListener listener = call.Enqueue();

                // attach handlers to the various events
                listener.Close += (sender, e) =>
                {
                    RunOnUiThread(() => adapter.Add(string.Format("{0}: {1}", e.Code, e.Reason)));
                };
                listener.Failure += (sender, e) =>
                {
                    if (e.Exception != null)
                    {
                        RunOnUiThread(() => adapter.Add(e.Exception.Message));
                    }
                    else
                    {
                        RunOnUiThread(() => adapter.Add("Unknown Error!"));
                    }
                };
                listener.Message += (sender, e) =>
                {
                    string payload = e.Payload.String();
                    e.Payload.Close();
                    RunOnUiThread(() => adapter.Add(string.Format("{0}\n{1}", payload, e.Payload.ContentType())));
                };
                listener.Open += (sender, e) =>
                {
                    RunOnUiThread(() => adapter.Add("Opened Web Socket."));

                    StartMessages(e.WebSocket);
                };
                listener.Pong += (sender, e) =>
                {
                    string payload = e.Payload.ReadString(Charset.DefaultCharset());
                    e.Payload.Close();
                    RunOnUiThread(() => adapter.Add(payload));
                };
            };
        }
コード例 #39
0
 string GetAsianHanja( Charset charset )
 {
     if ( charset.HasFlag ( Charset.AsianHanja ) )
     {
         StringBuilder stringBuilder = new StringBuilder ();
         for ( int i = 0x4E00; i <= 0x9FBF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0xF900; i <= 0xFAFF; i++ )
             stringBuilder.Append ( ( char ) i );
         return stringBuilder.ToString ();
     }
     else return "";
 }
コード例 #40
0
 public DecodingOptions(DecodingFlags decodingFlags, Encoding encoding)
 {
     this.decodingFlags = decodingFlags;
     this.charset       = ((encoding == null) ? null : Charset.GetCharset(encoding));
 }
コード例 #41
0
 string GetEnglishAlphabets( Charset charset )
 {
     if ( charset.HasFlag ( Charset.EnglishAlphabet ) )
         return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     else return "";
 }
コード例 #42
0
 public DecodingOptions(DecodingFlags decodingFlags, string charsetName)
 {
     this.decodingFlags = decodingFlags;
     this.charset       = ((charsetName == null) ? null : Charset.GetCharset(charsetName));
 }
コード例 #43
0
 string GetLatinAlphabets( Charset charset )
 {
     if ( charset.HasFlag ( Charset.LatinAdditionalChars ) )
     {
         StringBuilder stringBuilder = new StringBuilder ();
         for ( int i = 0x0100; i <= 0x017F; i++ )
             stringBuilder.Append ( ( char ) i );
         return stringBuilder.ToString ();
     }
     else return "";
 }
コード例 #44
0
 static public string GetUniqueKeyOriginal_BIASED(int size, Charset charset)
 {
     return(GetUniqueKeyOriginal_BIASED_Internal(size, charset));
 }
コード例 #45
0
 string GetUnicodeSpecialMarks( Charset charset )
 {
     if ( charset.HasFlag ( Charset.UnicodeSpecialChars ) )
     {
         StringBuilder stringBuilder = new StringBuilder ();
         for ( int i = 0x2460; i <= 0x24FF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x3000; i <= 0x303F; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x3200; i <= 0x32FF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x3300; i <= 0x33FF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2580; i <= 0x259F; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2500; i <= 0x257F; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x25A0; i <= 0x25FF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2600; i <= 0x26FF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2190; i <= 0x21FF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2200; i <= 0x22FF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2300; i <= 0x23FF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x20A0; i <= 0x20CF; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2100; i <= 0x214F; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2150; i <= 0x218F; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2000; i <= 0x206F; i++ )
             stringBuilder.Append ( ( char ) i );
         for ( int i = 0x2070; i <= 0x209F; i++ )
             stringBuilder.Append ( ( char ) i );
         return stringBuilder.ToString ();
     }
     else return "";
 }
コード例 #46
0
 public static Descriptor MarshalNativeToManaged(Charset charset, IntPtr pNativeData)
 {
     return(MarshalNativeToManaged(charset, pNativeData, false));
 }
コード例 #47
0
ファイル: Charset.cs プロジェクト: Rhombulus/Mime
 public static bool TryGetCharset(string name, out Charset charset)
 {
     if (name == null) {
         charset = null;
         return false;
     }
     if (CultureCharsetDatabase.Data.NameToCharset.TryGetValue(name, out charset))
         return true;
     if (name.StartsWith("cp", System.StringComparison.OrdinalIgnoreCase) || name.StartsWith("ms", System.StringComparison.OrdinalIgnoreCase)) {
         var codePage = 0;
         for (var index = 2; index < name.Length; ++index) {
             if (name[index] < 48 || name[index] > 57)
                 return false;
             codePage = codePage*10 + (name[index] - 48);
             if (codePage >= 65536)
                 return false;
         }
         if (codePage == 0)
             return false;
         return Charset.TryGetCharset(codePage, out charset);
     }
     return (Charset.FallbackToDefaultCharset && Charset.DefaultMimeCharset != null ||
             !Charset.FallbackToDefaultCharset && Charset.DefaultMimeCharset != null && Charset.DefaultMimeCharset.Name.Equals("iso-2022-jp", System.StringComparison.OrdinalIgnoreCase)) &&
            CultureCharsetDatabase.Data.NameToCharset.TryGetValue(Charset.DefaultMimeCharset.Name, out charset);
 }
コード例 #48
0
        private static string GetString(Charset charset, byte[] buffer)
        {
            var value = charset.GetString(buffer);

            return(value.TrimEnd('\0', ' '));
        }
コード例 #49
0
ファイル: Charset.cs プロジェクト: Rhombulus/Mime
 public static bool TryGetCharset(System.Text.Encoding encoding, out Charset charset)
 {
     return Charset.TryGetCharset(encoding.CodePage, out charset);
 }
コード例 #50
0
 private static string GetString(Charset charset, byte[] buffer, short bufferLength)
 {
     return(charset.GetString(buffer, 0, bufferLength));
 }
コード例 #51
0
 public ZipInputStream(InputStream arg0, Charset arg1)
     : base(ProxyCtor.I)
 {
     Instance.CallConstructor("(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V", arg0, arg1);
 }
コード例 #52
0
        private static IServiceManager CreateManagedServiceManager(FbConnectionString options)
        {
            var connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.PacketSize, Charset.GetCharset(options.Charset), options.Compression);

            connection.Connect();
            connection.Identify(!string.IsNullOrEmpty(options.Database) ? options.Database : string.Empty);

            switch (connection.ProtocolVersion)
            {
            case IscCodes.PROTOCOL_VERSION13:
            case IscCodes.PROTOCOL_VERSION12:
            case IscCodes.PROTOCOL_VERSION11:
            case IscCodes.PROTOCOL_VERSION10:
                return(new Client.Managed.Version10.GdsServiceManager(connection));

            default:
                throw UnsupportedProtocolException();
            }
        }
コード例 #53
0
ファイル: RegexTests.cs プロジェクト: TheFellow/RegexLib
        public static void test_charset()
        {
            var context = new Context("a1b2c3d4e5f6");
            var cset = new Charset();
            cset.Include('a');
            cset.Include('b', 'e');
            cset.Include('0', '9');

            var pos = new Possessive(cset, 0);

            // ([ab-e0-9]*)
            ExecTest(context, pos);
        }
コード例 #54
0
 /// <summary>
 /// Constructs a parse tree for a Declare Function statement.
 /// </summary>
 /// <param name="attributes">The attributes for the parse tree.</param>
 /// <param name="modifiers">The modifiers for the parse tree.</param>
 /// <param name="keywordLocation">The location of the keyword.</param>
 /// <param name="charsetLocation">The location of the 'Ansi', 'Auto' or 'Unicode', if any.</param>
 /// <param name="charset">The charset.</param>
 /// <param name="functionLocation">The location of 'Function'.</param>
 /// <param name="name">The name of the declaration.</param>
 /// <param name="libLocation">The location of 'Lib', if any.</param>
 /// <param name="libLiteral">The library, if any.</param>
 /// <param name="aliasLocation">The location of 'Alias', if any.</param>
 /// <param name="aliasLiteral">The alias, if any.</param>
 /// <param name="parameters">The parameters of the declaration.</param>
 /// <param name="asLocation">The location of the 'As', if any.</param>
 /// <param name="resultTypeAttributes">The attributes on the result type, if any.</param>
 /// <param name="resultType">The result type, if any.</param>
 /// <param name="span">The location of the parse tree.</param>
 /// <param name="comments">The comments for the parse tree.</param>
 public ExternalFunctionDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, Location charsetLocation, Charset charset, Location functionLocation, SimpleName name, Location libLocation, StringLiteralExpression libLiteral, Location aliasLocation,
                                    StringLiteralExpression aliasLiteral, ParameterCollection parameters, Location asLocation, AttributeBlockCollection resultTypeAttributes, TypeName resultType, Span span, IList <Comment> comments) : base(TreeType.ExternalFunctionDeclaration, attributes, modifiers, keywordLocation, charsetLocation, charset, functionLocation, name, libLocation, libLiteral,
                                                                                                                                                                                                                                               aliasLocation, aliasLiteral, parameters, asLocation, resultTypeAttributes, resultType, span, comments)
 {
 }
コード例 #55
0
	  /// <summary>
	  /// Accesses a resource by name and returns the (non comment) lines containing
	  /// data using the given character encoding.
	  /// 
	  /// <para>
	  /// A comment line is any line that starts with the character "#"
	  /// </para>
	  /// </summary>
	  /// <returns> a list of non-blank non-comment lines with whitespace trimmed </returns>
	  /// <exception cref="IOException"> If there is a low-level I/O error. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static java.util.List<String> getLines(java.io.InputStream stream, java.nio.charset.Charset charset) throws java.io.IOException
	  public static IList<string> getLines(InputStream stream, Charset charset)
	  {
		BufferedReader input = null;
		List<string> lines;
		bool success = false;
		try
		{
		  input = getBufferedReader(IOUtils.getDecodingReader(stream, charset));

		  lines = new List<>();
		  for (string word = null; (word = input.readLine()) != null;)
		  {
			// skip initial bom marker
			if (lines.Count == 0 && word.Length > 0 && word[0] == '\uFEFF')
			{
			  word = word.Substring(1);
			}
			// skip comments
			if (word.StartsWith("#", StringComparison.Ordinal))
			{
				continue;
			}
			word = word.Trim();
			// skip blank lines
			if (word.length() == 0)
			{
				continue;
			}
			lines.Add(word);
		  }
		  success = true;
		  return lines;
		}
		finally
		{
		  if (success)
		  {
			IOUtils.close(input);
		  }
		  else
		  {
			IOUtils.closeWhileHandlingException(input);
		  }
		}
	  }
コード例 #56
0
        // Token: 0x06000717 RID: 1815 RVA: 0x0003786C File Offset: 0x00035A6C
        private static int SendDocumentContentToHttpStream(HttpContext httpContext, Stream stream, string fileName, string fileExtension, string contentType, bool isInline, Charset charset, BlockStatus blockStatus, AttachmentPolicy.Level level, bool doNeedToFilterHtml)
        {
            if (AttachmentUtility.IsMhtmlAttachment(contentType, fileExtension))
            {
                ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string>(0L, "AttachmentHandler.SendDocumentContentToHttpStream: Explicitly blocking MHTML attachment {0}", fileName);
                return(0);
            }
            AttachmentHandler.SetAttachmentResponseHeaders(httpContext, fileName, contentType, isInline, level);
            uint result;

            if (doNeedToFilterHtml)
            {
                result = AttachmentUtility.WriteFilteredResponse(httpContext, stream, charset, blockStatus);
            }
            else
            {
                bool isNotHtmlandNotXml = !AttachmentUtility.GetIsHtmlOrXml(contentType, fileExtension);
                bool doNotSniff         = AttachmentUtility.GetDoNotSniff(level, OwaContext.Get(httpContext).UserContext);
                result = AttachmentUtility.WriteUnfilteredResponse(httpContext, stream, fileName, isNotHtmlandNotXml, doNotSniff);
            }
            return((int)result);
        }
コード例 #57
0
ファイル: TagFormExtension.cs プロジェクト: bzure/BSA.Net
 public static TagForm acceptcharset(this TagForm tag, Charset[] value) { tag.AcceptCharset = value; return tag; }
コード例 #58
0
        public static IscException ParseStatusVector(IntPtr[] statusVector, Charset charset)
        {
            IscException exception = null;
            bool         eof       = false;

            for (int i = 0; i < statusVector.Length;)
            {
                IntPtr arg = statusVector[i++];

                switch (arg.AsInt())
                {
                case IscCodes.isc_arg_gds:
                default:
                    IntPtr er = statusVector[i++];
                    if (er != IntPtr.Zero)
                    {
                        if (exception == null)
                        {
                            exception = IscException.ForBuilding();
                        }
                        exception.Errors.Add(new IscError(arg.AsInt(), er.AsInt()));
                    }
                    break;

                case IscCodes.isc_arg_end:
                    exception?.BuildExceptionData();
                    eof = true;
                    break;

                case IscCodes.isc_arg_interpreted:
                case IscCodes.isc_arg_string:
                {
                    IntPtr ptr       = statusVector[i++];
                    string s         = Marshal.PtrToStringAnsi(ptr);
                    string arg_value = charset.GetString(Encoding.UTF8.GetBytes(s));
                    exception.Errors.Add(new IscError(arg.AsInt(), arg_value));
                }
                break;

                case IscCodes.isc_arg_cstring:
                {
                    i++;

                    IntPtr ptr       = statusVector[i++];
                    string s         = Marshal.PtrToStringAnsi(ptr);
                    string arg_value = charset.GetString(Encoding.UTF8.GetBytes(s));
                    exception.Errors.Add(new IscError(arg.AsInt(), arg_value));
                }
                break;

                case IscCodes.isc_arg_win32:
                case IscCodes.isc_arg_number:
                    exception.Errors.Add(new IscError(arg.AsInt(), statusVector[i++].AsInt()));
                    break;

                case IscCodes.isc_arg_sql_state:
                {
                    IntPtr ptr       = statusVector[i++];
                    string s         = Marshal.PtrToStringAnsi(ptr);
                    string arg_value = charset.GetString(Encoding.UTF8.GetBytes(s));
                    exception.Errors.Add(new IscError(arg.AsInt(), arg_value));
                }
                break;
                }

                if (eof)
                {
                    break;
                }
            }

            return(exception);
        }
コード例 #59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OcrKing"/> class.
 /// </summary>
 /// <param name="apiKey">
 /// 授权ApiKey,获取方式请看群共享中的文档说明
 /// </param>
 /// <param name="apiUrl">
 /// 服务请求地址,当您使用的地址不能正常访问时
 ///     请通过 http://api.ocrking.com/server.html 获取
 ///     后台不定时增加或减少请求地址,
 /// </param>
 public OcrKing(string apiKey, string apiUrl)
 {
     this.ApiKey = apiKey;
     this.apiUrl = string.IsNullOrEmpty(apiUrl) ? DefaultApiUrl : apiUrl.Trim();
     this.Language = Language.Eng;
     this.charset = Charset.Default;
     this.service = Service.OcrKingForCaptcha;
     this.formData = new NameValueCollection();
 }
コード例 #60
0
 public FesServiceManager(string dllName, Charset charset)
 {
     this.fbClient     = FbClientFactory.GetFbClient(dllName);
     this.charset      = (charset != null ? charset : Charset.DefaultCharset);
     this.statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];
 }