• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Text.Encoding类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Load

        public virtual void Load( string fileName, Encoding encoding )
        {
            if ( fileName == null )
            {
                return;
            }
            throw new System.NotSupportedException();
            /*
            string text;
            if (encoding == null)
                text = File.re.ReadAllText(fileName);
            else
                text = File.ReadAllText(fileName, encoding);

            data = text.ToCharArray();
            n = data.Length;*/
        }
开发者ID:joelmartinez,项目名称:Jint.Phone,代码行数:17,代码来源:ANTLRFileStream.cs


示例17: Encoding

        static Encoding()
        {
            defLangMap.Add("English", new FontLangInfo(1252, 1033, 0));
              defLangMap.Add("Czech", new FontLangInfo(1252, 1029, 238));
              defLangMap.Add("French", new FontLangInfo(1252, 1036, 0));
              defLangMap.Add("German", new FontLangInfo(1252, 1031, 0));
              defLangMap.Add("Italian", new FontLangInfo(1252, 1040, 0));
              defLangMap.Add("Spanish", new FontLangInfo(1252, 1034, 0));
              defLangMap.Add("Russian", new FontLangInfo(1251, 1049, 204));
              defLangMap.Add("Polish", new FontLangInfo(1250, 1045, 0));

              defLangMap.Add("Japanese", new FontLangInfo(932, 1041, 128)); //128 => i'm not sure but i find on the web SHIFTJIS_CHARSET = 128
              //http://www.tek-tips.com/viewthread.cfm?qid=712495
              //Private Const DEFAULT_CHARSET = 1
              //Private Const SYMBOL_CHARSET = 2
              //Private Const SHIFTJIS_CHARSET = 128
              //Private Const HANGEUL_CHARSET = 129
              //Private Const CHINESEBIG5_CHARSET = 136
              //Private Const CHINESESIMPLIFIED_CHARSET = 134

              CP1252 = Properties.Settings.Default.UseUTF8 ? s_UTF8Encoding : s_CP1252Encoding;
        }
开发者ID:SmaugNogardeht,项目名称:tesvsnip,代码行数:22,代码来源:Program.cs


示例18: Load

        /// <exception cref="System.IO.IOException"/>
        public virtual void Load(string fileName, Encoding encoding)
        {
            if (fileName == null)
            {
                return;
            }

            string text;
#if !COMPACT
            if (encoding != null)
                text = File.ReadAllText(fileName, encoding);
            else
                text = File.ReadAllText(fileName);
#else
            if (encoding != null)
                text = ReadAllText(fileName, encoding);
            else
                text = ReadAllText(fileName);
#endif

            data = text.ToCharArray();
            n = data.Length;
        }
开发者ID:RainerBosch,项目名称:antlr4,代码行数:24,代码来源:AntlrFileStream.cs


示例19: SetEncoding

		public void SetEncoding(string encoding)
		{
			encoding = encoding.ToUpper();
			if (encoding == "UTF-8")
				this.encoding = System.Text.Encoding.UTF8;
			else if (encoding == "UTF-16")
				this.encoding = System.Text.Encoding.Unicode;
			else if (encoding == "UTF-7")
				this.encoding = System.Text.Encoding.UTF7;
			else if (encoding == "US-ASCII")
				this.encoding = System.Text.Encoding.ASCII;
			else
			{
				try
				{
					this.encoding = System.Text.Encoding.GetEncoding( encoding );
				}
				catch( NotSupportedException )
				{
					throw new XmlException("Unknown encoding");
				}
			}
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:23,代码来源:Document.cs


示例20: EntityBodyInspector

        internal EntityBodyInspector(HttpUploadWorkerRequest request)
        {
            statistic = new UploadProgressStatistic();
            
            statistic.TotalBytes = request.GetTotalEntityBodyLength();

            string contentType = request.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentType);

            string boundary = string.Format("--{0}\r\n", UploadProgressUtils.GetBoundary(contentType));
            _encoding = System.Text.Encoding.UTF8;

            _boundaryWaiter = new EntityBodyChunkStateWaiter(boundary, false);
            _boundaryWaiter.MeetGuard += new EventHandler<EventArgs>(boundaryWaiter_MeetGuard);
            _current = _boundaryWaiter;

            _boundaryInfoWaiter = new EntityBodyChunkStateWaiter("\r\n\r\n", true);
            _boundaryInfoWaiter.MeetGuard += new EventHandler<EventArgs>(boundaryInfoWaiter_MeetGuard);

            _formValueWaiter = new EntityBodyChunkStateWaiter("\r\n", true);
            _formValueWaiter.MeetGuard += new EventHandler<EventArgs>(formValueWaiter_MeetGuard);

            _lastCdName = string.Empty;
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:23,代码来源:EntityBodyInspector.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RegularExpressions.Regex类代码示例发布时间:2022-05-24
下一篇:
C# Text.ASCIIEncoding类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap