当前位置: 首页>>代码示例>>C#>>正文


C# Text.Encoding类代码示例

本文整理汇总了C#中System.Text.Encoding的典型用法代码示例。如果您正苦于以下问题:C# System.Text.Encoding类的具体用法?C# System.Text.Encoding怎么用?C# System.Text.Encoding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.Text.Encoding类属于命名空间,在下文中一共展示了System.Text.Encoding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Message

 internal Message(byte[] data, TcpClient tcpClient, System.Text.Encoding stringEncoder, byte lineDelimiter)
 {
     Data = data;
     TcpClient = tcpClient;
     _encoder = stringEncoder;
     _writeLineDelimiter = lineDelimiter;
 }
开发者ID:CloneMMDDCVII,项目名称:Werewolf,代码行数:7,代码来源:Message.cs

示例2: UrlEncode

        internal static string UrlEncode(string str, Encoding e)
        {
            if (str == null)
                return null;

            return Encoding.ASCII.GetString(UrlEncodeToBytes(str, e));
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:7,代码来源:HttpUtility.cs

示例3: CompressString

        //Direct Compression/Decompression
        public CompressString(System.Text.Encoding TextEncoding, string InputString, InputDataTypeClass InputDataType, string Passphrase = "", string PrefixForCompressedString = "", string SuffixForCompressedString = "")
        {
            this._TextEncoding = TextEncoding;
            this._PrefixForCompressedString = PrefixForCompressedString;
            this._SuffixForCompressedString = SuffixForCompressedString;
            this._Passphrase = Passphrase;

            switch (InputDataType)
            {
                case InputDataTypeClass.UnCompressed:
                    this._UnCompressed = InputString;
                    this.Compress();
                    break;
                case InputDataTypeClass.Compressed:
                    string Result = InputString;
                    if (Result.Length > 0 & Result.Length > (this._PrefixForCompressedString.Length + this._SuffixForCompressedString.Length))
                    {
                        if (this._PrefixForCompressedString.Length > 0)
                        {
                            Result = InputString.Substring(this._PrefixForCompressedString.Length, Result.Length - this._PrefixForCompressedString.Length);
                        }
                        if (this._SuffixForCompressedString.Length > 0)
                        {
                            Result = Result.Substring(0, Result.Length - this._SuffixForCompressedString.Length);
                        }
                    }
                    this._Compressed = Result;
                    this._CompressedGiven = true;
                    this.Decompress();
                    break;
            }
        }
开发者ID:sandeeplocality,项目名称:UG12Server,代码行数:33,代码来源:CompressString.cs

示例4: Create

        public static Action<HttpContextBase> Create(IEnumerable<string> resourceNames, string mediaType, Encoding responseEncoding, bool cacheResponse)
        {
            Debug.Assert(resourceNames != null);
            Debug.AssertStringNotEmpty(mediaType);

            return context =>
            {
                //
                // Set the response headers for indicating the content type
                // and encoding (if specified).
                //

                var response = context.Response;
                response.ContentType = mediaType;

                if (cacheResponse)
                {
                    response.Cache.SetCacheability(HttpCacheability.Public);
                    response.Cache.SetExpires(DateTime.MaxValue);
                }

                if (responseEncoding != null)
                    response.ContentEncoding = responseEncoding;

                foreach (var resourceName in resourceNames)
                    ManifestResourceHelper.WriteResourceToStream(response.OutputStream, resourceName);
            };
        }
开发者ID:boena,项目名称:elmah-with-custom-data,代码行数:28,代码来源:ManifestResourceHandler.cs

示例5: ReadAllText

 private static string ReadAllText(string path, Encoding encoding)
 {
     using (var reader = new StreamReader(path, encoding ?? Encoding.Default))
     {
         return reader.ReadToEnd();
     }
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:7,代码来源:AntlrFileStream.cs

示例6: CsvOptions

 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 /// <param name="encoding">The encoding.</param>
 public CsvOptions(System.Text.Encoding encoding)
 {
     // Initialize field members.
     this._encoding = encoding;
     this._hasHeader = false;
     this._seperator = ',';
     this._stringCharacter = '"';
 }
开发者ID:Nevets82,项目名称:CsvLibrary,代码行数:12,代码来源:CsvOptions.cs

示例7: LCD4Bit

        /// <summary>
        /// Creates new intstance of HD44780 LCD display in 4-bit mode.
        /// </summary>
        /// <param name="provider">Data transfer provider.</param>
        public LCD4Bit(ITransferProvider provider)
        {
            this.Provider = provider;

            this.Encoding = System.Text.Encoding.UTF8;
            this._backLight = false;

            Init(true);
        }
开发者ID:PavelBansky,项目名称:microframework,代码行数:13,代码来源:LCD4Bit.cs

示例8: ManifestResourceHandler

        public ManifestResourceHandler(string resourceName, string contentType, Encoding responseEncoding)
        {
            Debug.AssertStringNotEmpty(resourceName);
            Debug.AssertStringNotEmpty(contentType);

            _resourceName = resourceName;
            _contentType = contentType;
            _responseEncoding = responseEncoding;
        }
开发者ID:kjana83,项目名称:ELMAH,代码行数:9,代码来源:ManifestResourceHandler.cs

示例9: DefaultContextModelContextBase

		/// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="modelData"></param>
        public DefaultContextModelContextBase(DslEditorModeling::ModelData modelData) 
			: base(modelData)
        {
			encodingXml = System.Text.Encoding.GetEncoding("ISO-8859-1");
			
			//validationController = VSPluginDSLValidationController.Instance;
			//validationController.Initialize();			
			serializationResult = new DslEditorModeling::SerializationResult();
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:13,代码来源:ModelContexts.cs

示例10: Load

        public virtual void Load( string fileName, Encoding encoding )
        {
            if ( fileName == null )
            {
                return;
            }

            data = System.IO.File.ReadAllText( fileName, encoding ).ToCharArray();
            n = data.Length;
        }
开发者ID:ksmyth,项目名称:antlr,代码行数:10,代码来源:ANTLRFileStream.cs

示例11: Main

    static System.IO.FileStream fs; //файловый поток - (запись/чтение) в файл двоичных данных

    #endregion Fields

    #region Methods

    static void Main()
    {
        enc = System.Text.Encoding.GetEncoding(1251);

         fs = new System.IO.FileStream("log.txt", System.IO.FileMode.Create , System.IO.FileAccess.Write ); //на запись
         bw = new System.IO.BinaryWriter(fs, enc);    //инициализация файловым потоком, с указанием рабочей кодировки

         //по умолчанию запись идет в кодировке utf8
         SayFile("{0} - {1} - {2}", "Hello", "File", "Приветик");
         fs.Close();
    }
开发者ID:akmaplus,项目名称:My_sources_cs,代码行数:17,代码来源:sayfile.cs

示例12: IntermediateCreateAndRegisterStream

 //New implementation of the CreateAndRegisterStream method
 // Using in Render
 public System.IO.Stream IntermediateCreateAndRegisterStream(string name, string extension, System.Text.Encoding encoding, string mimeType
     , bool willSeek, Microsoft.ReportingServices.Interfaces.StreamOper operation)
 {
     _name = name;
     _encoding = encoding;
     _extension = extension;
     _mimeType = mimeType;
     _operation = operation;
     _willSeek = willSeek;
     intermediateStream = new System.IO.MemoryStream();
     return intermediateStream;
 }
开发者ID:ststeiger,项目名称:ReportViewerWrapper,代码行数:14,代码来源:custext.cs

示例13: ANTLRInputStream

 public ANTLRInputStream( Stream input, int size, int readBufferSize, Encoding encoding )
 {
     StreamReader isr;
     if ( encoding != null )
     {
         isr = new StreamReader( input, encoding );
     }
     else
     {
         isr = new StreamReader( input );
     }
     Load( isr, size, readBufferSize );
 }
开发者ID:ksmyth,项目名称:antlr,代码行数:13,代码来源:ANTLRInputStream.cs

示例14: RemapEncoding

 public RemapEncoding(int codePage)
     : base(codePage)
 {
     if (codePage == 28591) {
         encodingEncoding = System.Text.Encoding.GetEncoding(28591);
         decodingEncoding = System.Text.Encoding.GetEncoding(1252);
     } else {
         if (codePage != 28599)
             throw new System.ArgumentException();
         encodingEncoding = System.Text.Encoding.GetEncoding(28599);
         decodingEncoding = System.Text.Encoding.GetEncoding(1254);
     }
 }
开发者ID:Rhombulus,项目名称:Mime,代码行数:13,代码来源:RemapEncoding.cs

示例15: Load

        public virtual void Load( string fileName, Encoding encoding )
        {
            if ( fileName == null )
            {
                return;
            }

            string text;
            if (encoding == null)
                text = File.ReadAllText(fileName);
            else
                text = File.ReadAllText(fileName, encoding);

            data = text.ToCharArray();
            n = data.Length;
        }
开发者ID:EightPillars,项目名称:PathwayEditor,代码行数:16,代码来源:ANTLRFileStream.cs


注:本文中的System.Text.Encoding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。