Skip the encoding process for 'safe strings' - CSharp System

CSharp examples for System:String Encode Decode

Description

Skip the encoding process for 'safe strings'

Demo Code

// Licensed under the same terms of ServiceStack: new BSD license.
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from w  ww .  java  2 s .c  o  m*/

public class Main{
        /// <summary>
		/// Skip the encoding process for 'safe strings' 
		/// </summary>
		/// <param name="strVal"></param>
		/// <returns></returns>
		private static byte[] FastToUtf8Bytes(string strVal)
		{
			var bytes = new byte[strVal.Length];
			for (var i = 0; i < strVal.Length; i++)
				bytes[i] = (byte)strVal[i];
			
			return bytes;
		}
}

Related Tutorials