本文整理汇总了C#中System.Text.Encoding.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.Encoding.GetBytes方法的具体用法?C# System.Text.Encoding.GetBytes怎么用?C# System.Text.Encoding.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.Encoding
的用法示例。
在下文中一共展示了System.Text.Encoding.GetBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setDownLoadedBytes
/// <summary>
/// Remember to manage the URL and set it to some defualt stuff
/// </summary>
public void setDownLoadedBytes(string HTMLData)
{
if (!string.IsNullOrEmpty(HTMLData))
{
DownloadedBytes = StrToByteArray(HTMLData);
_WasDownloaded = true;
_ContentType = "text/html";
_ContentLocation = " ";
_TextEncoding = System.Text.Encoding.GetEncoding("Windows-1252");
//'Me.Url = _ContentLocation
if (IsHtml)
{
_DownloadedBytes = _TextEncoding.GetBytes(ProcessHtml(ToString()));
}
if (IsCss)
{
_DownloadedBytes = _TextEncoding.GetBytes(ProcessCss(ToString()));
}
if (Storage != Builder.FileStorage.Memory)
{
SaveToFile();
}
}
}
示例2: UriEncodeFragment
private static string UriEncodeFragment(string text, Encoding encoding)
{
if (text == null)
throw new ArgumentNullException("text");
if (encoding == null)
throw new ArgumentNullException("encoding");
if (text.Length == 0)
return text;
StringBuilder builder = new StringBuilder();
byte[] data = encoding.GetBytes(text);
for (int i = 0; i < data.Length; i++)
{
if (_allowedFragmentCharacters[data[i]])
builder.Append((char)data[i]);
else
builder.Append('%').Append(data[i].ToString("x2"));
}
return builder.ToString();
}
示例3: UrlEncodeToBytes
internal static byte[] UrlEncodeToBytes(string str, Encoding e)
{
if (str == null)
return null;
byte[] bytes = e.GetBytes(str);
return UrlEncode(bytes, 0, bytes.Length, false);
}
示例4: UriEncodeAnyUrl
private static string UriEncodeAnyUrl(string text, Encoding encoding)
{
if (text == null)
throw new ArgumentNullException("text");
if (encoding == null)
throw new ArgumentNullException("encoding");
if (text.Length == 0)
return text;
StringBuilder builder = new StringBuilder();
byte[] data = encoding.GetBytes(text);
for (int i = 0; i < data.Length; i++)
{
if (_unreservedCharacters[data[i]])
{
builder.Append((char)data[i]);
}
else
{
switch ((char)data[i])
{
case '(':
case ')':
case '*':
case '!':
builder.Append((char)data[i]);
break;
default:
builder.Append('%').Append(data[i].ToString("x2"));
break;
}
}
}
return builder.ToString();
}