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


C# UTF8Encoding.Remove方法代码示例

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


在下文中一共展示了UTF8Encoding.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRemoteResourceContent

 public string GetRemoteResourceContent(CombinatorResource resource)
 {
     using (var wc = new WebClient())
     {
         var byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
         var content = new UTF8Encoding(false).GetString(wc.DownloadData(resource.AbsoluteUrl));
         if (content.StartsWith(byteOrderMarkUtf8)) // Stripping "?"s from the beginning of css commments "/*"
         {
             content = content.Remove(0, byteOrderMarkUtf8.Length);
         }
         return content;
     }
 }
开发者ID:GiscardBiamby,项目名称:combinator,代码行数:13,代码来源:ResourceFileService.cs

示例2: Do

		public void Do()
		{
			//
			string utf8Bom = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());

			//
			appUrl = url;
			appPath = ".\\";
			appName = url.Substring(url.LastIndexOf('/') + 1);
			appData = HttpHelper.GetData(appUrl);
			appXml = new System.Text.UTF8Encoding(false).GetString(appData);
			if (appXml.StartsWith(utf8Bom)) appXml = appXml.Remove(0, utf8Bom.Length);
			Console.WriteLine(string.Format("load {0}", appUrl));

			//
			string manifestCodebase = ParseAppXml(appXml);

			//
			manifestUrl = appUrl.Substring(0, url.LastIndexOf('/') + 1) + manifestCodebase.Replace('\\', '/');
			manifestPath = manifestCodebase.Substring(0, manifestCodebase.LastIndexOf('\\') + 1);
			manifestName = manifestCodebase.Substring(manifestCodebase.LastIndexOf('\\') + 1);
			manifestData = HttpHelper.GetData(manifestUrl);
			manifestXml = System.Text.Encoding.UTF8.GetString(manifestData);
			if (manifestXml.StartsWith(utf8Bom)) manifestXml = manifestXml.Remove(0, utf8Bom.Length);
			Console.WriteLine(string.Format("load {0}", manifestUrl));

			//
			List<Item> items = ParseManifestXml(manifestXml);

			//
			string taskXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
			taskXml += "<files>\r\n";
			for (int i = 0; i < items.Count; i++)
			{
				string name = items[i].name;
				int size = items[i].size;
				string filePath = manifestPath;
				string fileName = name;
				if (name.LastIndexOf('\\') > 0)
				{
					filePath += name.Substring(0, name.LastIndexOf('\\') + 1);
					fileName = name.Substring(name.LastIndexOf('\\') + 1);
				}
				string fileUrl = manifestUrl.Substring(0, manifestUrl.LastIndexOf('/') + 1) + name.Replace('\\', '/');
				fileName += ".deploy";
				fileUrl += ".deploy";
				taskXml += string.Format("<file FilePath=\"{0}\" FileName=\"{1}\" FileSize=\"{2}\" Url=\"{3}\"/>\r\n", filePath, fileName, size, fileUrl);
			}
			taskXml += "</files>\r\n";

			//
			Directory.CreateDirectory(task);

			Directory.CreateDirectory(task + "\\" + appPath);
			File.WriteAllBytes(task + "\\" + appPath + appName, appData);

			Directory.CreateDirectory(task + "\\" + manifestPath);
			File.WriteAllBytes(task + "\\" + manifestPath + manifestName, manifestData);

			File.WriteAllText(task + ".xml", taskXml);

			//
			Console.WriteLine(string.Format("CreateTask [{0}] Complete!", task));
		}
开发者ID:chengpu,项目名称:OneClickDownloader,代码行数:64,代码来源:CreateTask.cs


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