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


C# Encoding.Check方法代码示例

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


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

示例1: ToByteArray

 /// <summary>
 /// Converts a string to a byte array
 /// </summary>
 /// <param name="Input">input string</param>
 /// <param name="EncodingUsing">The type of encoding the string is using (defaults to UTF8)</param>
 /// <returns>the byte array representing the string</returns>
 public static byte[] ToByteArray(this string Input, Encoding EncodingUsing = null)
 {
     return string.IsNullOrEmpty(Input) ? new byte[0] : EncodingUsing.Check(new UTF8Encoding()).GetBytes(Input);
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:10,代码来源:StringExtensions.cs

示例2: ToString

 /// <summary>
 /// Converts from the specified encoding to a base 64 string
 /// </summary>
 /// <param name="Input">Input string</param>
 /// <param name="Options">Base 64 formatting options</param>
 /// <param name="OriginalEncodingUsing">
 /// The type of encoding the string is using (defaults to UTF8)
 /// </param>
 /// <returns>Bas64 string</returns>
 public static string ToString(this string Input, Base64FormattingOptions Options, Encoding OriginalEncodingUsing = null)
 {
     if (string.IsNullOrEmpty(Input))
         return "";
     byte[] TempArray = OriginalEncodingUsing.Check(new UTF8Encoding()).GetBytes(Input);
     return Convert.ToBase64String(TempArray, Options);
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:16,代码来源:StringExtensions.cs

示例3: FromBase64

 /// <summary>
 /// Converts base 64 string based on the encoding passed in
 /// </summary>
 /// <param name="Input">Input string</param>
 /// <param name="EncodingUsing">The type of encoding the string is using (defaults to UTF8)</param>
 /// <returns>string in the encoding format</returns>
 public static string FromBase64(this string Input, Encoding EncodingUsing)
 {
     if (string.IsNullOrEmpty(Input))
         return "";
     byte[] TempArray = Convert.FromBase64String(Input);
     return EncodingUsing.Check(() => new UTF8Encoding()).GetString(TempArray);
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:13,代码来源:StringExtensions.cs

示例4: Encode

 /// <summary>
 /// Converts a string to a string of another encoding
 /// </summary>
 /// <param name="Input">input string</param>
 /// <param name="OriginalEncodingUsing">
 /// The type of encoding the string is currently using (defaults to ASCII)
 /// </param>
 /// <param name="EncodingUsing">
 /// The type of encoding the string is converted into (defaults to UTF8)
 /// </param>
 /// <returns>string of the byte array</returns>
 public static string Encode(this string Input, Encoding OriginalEncodingUsing = null, Encoding EncodingUsing = null)
 {
     if (string.IsNullOrEmpty(Input))
         return "";
     OriginalEncodingUsing = OriginalEncodingUsing.Check(new ASCIIEncoding());
     EncodingUsing = EncodingUsing.Check(new UTF8Encoding());
     return Encoding.Convert(OriginalEncodingUsing, EncodingUsing, Input.ToByteArray(OriginalEncodingUsing))
                    .ToString(EncodingUsing);
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:20,代码来源:StringExtensions.cs

示例5: ToString

 /// <summary>
 /// Converts a byte array to a string
 /// </summary>
 /// <param name="Input">input array</param>
 /// <param name="EncodingUsing">
 /// The type of encoding the string is using (defaults to UTF8)
 /// </param>
 /// <param name="Count">
 /// Number of bytes starting at the index to convert (use -1 for the entire array starting
 /// at the index)
 /// </param>
 /// <param name="Index">Index to start at</param>
 /// <returns>string of the byte array</returns>
 public static string ToString(this byte[] Input, Encoding EncodingUsing, int Index = 0, int Count = -1)
 {
     if (Input == null)
         return "";
     if (Count == -1)
         Count = Input.Length - Index;
     return EncodingUsing.Check(new UTF8Encoding()).GetString(Input, Index, Count);
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:21,代码来源:ValueTypeExtensions.cs

示例6: SaveAsync

 /// <summary>
 /// Saves a string to a file (asynchronously)
 /// </summary>
 /// <param name="File">File to save to</param>
 /// <param name="Content">Content to save to the file</param>
 /// <param name="CallBack">Call back function</param>
 /// <param name="StateObject">State object</param>
 /// <param name="EncodingUsing">Encoding that the content is using (defaults to ASCII)</param>
 /// <param name="Mode">Mode for saving the file (defaults to Create)</param>
 /// <returns>The FileInfo object</returns>
 public static FileInfo SaveAsync(this FileInfo File, string Content, AsyncCallback CallBack,
     object StateObject, FileMode Mode = FileMode.Create, Encoding EncodingUsing = null)
 {
     Contract.Requires<ArgumentNullException>(File != null, "File");
     return File.SaveAsync(EncodingUsing.Check(new ASCIIEncoding()).GetBytes(Content), CallBack, StateObject, Mode);
 }
开发者ID:kaytie,项目名称:Craig-s-Utility-Library,代码行数:16,代码来源:FileInfoExtensions.cs

示例7: Save

 /// <summary>
 /// Saves a string to a file
 /// </summary>
 /// <param name="File">File to save to</param>
 /// <param name="Content">Content to save to the file</param>
 /// <param name="EncodingUsing">Encoding that the content is using (defaults to ASCII)</param>
 /// <param name="Mode">Mode for saving the file (defaults to Create)</param>
 /// <returns>The FileInfo object</returns>
 public static FileInfo Save(this FileInfo File, string Content, FileMode Mode = FileMode.Create, Encoding EncodingUsing = null)
 {
     Contract.Requires<ArgumentNullException>(File != null, "File");
     return File.Save(EncodingUsing.Check(new ASCIIEncoding()).GetBytes(Content), Mode);
 }
开发者ID:kaytie,项目名称:Craig-s-Utility-Library,代码行数:13,代码来源:FileInfoExtensions.cs


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