本文整理汇总了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;
}
}
示例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));
}