using System; using System.Collections.Generic; using System.Text;
namespace FileManagement.BOL.Helper { public class NonPrintableCharacters { public static List<char> charList = new List<char>();
public NonPrintableCharacters () { //Refer to http://nemesis.lonestar.org/reference/telecom/codes/ascii.html charList.Add((char)Convert.ToInt16("0x01", 16)); //1 Start Of Heading charList.Add((char)Convert.ToInt16("0x02", 16)); //2 Start Of Text charList.Add((char)Convert.ToInt16("0x03", 16)); //3 End Of Text charList.Add((char)Convert.ToInt16("0x04", 16)); //4 End Of Transmission charList.Add((char)Convert.ToInt16("0x05", 16)); //5 Enquiry, Also known as WRU (Who aRe You), HERE IS, and Answerback charList.Add((char)Convert.ToInt16("0x06", 16)); //6 Acknowledge charList.Add((char)Convert.ToInt16("0x07", 16)); //7 Bell charList.Add((char)Convert.ToInt16("0x08", 16)); //8 Backspace //Line Feed 0x0A and Horizontal Tab 0x09 is allowed charList.Add((char)Convert.ToInt16("0x0B", 16)); //11 Vertical Tabulation charList.Add((char)Convert.ToInt16("0x0C", 16)); //12 Form Feed, //Carriage Return 0x0D is allowed charList.Add((char)Convert.ToInt16("0x0E", 16)); //14 Shift Out charList.Add((char)Convert.ToInt16("0x0F", 16)); //15 Shift In charList.Add((char)Convert.ToInt16("0x10", 16)); //15 Shift In charList.Add((char)Convert.ToInt16("0x11", 16)); //17 Device Control 1,Also known as X-ON charList.Add((char)Convert.ToInt16("0x12", 16)); //18 Device Control 2 charList.Add((char)Convert.ToInt16("0x13", 16)); //19 Device Control 3,Also known as X-OFF charList.Add((char)Convert.ToInt16("0x14", 16)); //20 Device Control 4 charList.Add((char)Convert.ToInt16("0x15", 16)); //21 Negative Acknowledge charList.Add((char)Convert.ToInt16("0x16", 16)); //22 Sychronous Idle charList.Add((char)Convert.ToInt16("0x17", 16)); //23 End of Transmission Block charList.Add((char)Convert.ToInt16("0x18", 16)); //24 Cancel charList.Add((char)Convert.ToInt16("0x19", 16)); //25 End of Medium charList.Add((char)Convert.ToInt16("0x1A", 16)); //26 Substitute charList.Add((char)Convert.ToInt16("0x1B", 16)); //27 Escape charList.Add((char)Convert.ToInt16("0x1C", 16)); //28 File Separator charList.Add((char)Convert.ToInt16("0x1D", 16)); //29 Group Separator charList.Add((char)Convert.ToInt16("0x1E", 16)); //30 Record Separator charList.Add((char)Convert.ToInt16("0x1F", 16)); //31 Unit Separator charList.Add((char)Convert.ToInt16("0x7F", 16)); //127 Delete, Also known as RUB OUT }
public string ReplaceInvalidChars(string mystring, char newChar) { foreach (char c in charList) mystring = mystring.Replace(c, newChar); return mystring; }
} }
|