本文整理汇总了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;
}
示例2: UrlEncode
internal static string UrlEncode(string str, Encoding e)
{
if (str == null)
return null;
return Encoding.ASCII.GetString(UrlEncodeToBytes(str, e));
}
示例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;
}
}
示例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);
};
}
示例5: ReadAllText
private static string ReadAllText(string path, Encoding encoding)
{
using (var reader = new StreamReader(path, encoding ?? Encoding.Default))
{
return reader.ReadToEnd();
}
}
示例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 = '"';
}
示例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);
}
示例8: ManifestResourceHandler
public ManifestResourceHandler(string resourceName, string contentType, Encoding responseEncoding)
{
Debug.AssertStringNotEmpty(resourceName);
Debug.AssertStringNotEmpty(contentType);
_resourceName = resourceName;
_contentType = contentType;
_responseEncoding = responseEncoding;
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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 );
}
示例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);
}
}
示例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;
}