Reputation: 36591
I've a string, In sql I've tested this string contains non-printable characters but I couldn't find which are those.
So can anyone suggest me how can i find and print those non-printable characters in C# by passing this string?
I ordered a Taurus in August and it hasn't been scheduled, I was just wondering if there is something wrong with the order? Or if the queue is just long? Order Number:8028Vehicle Rep:74JTag#: 200L049Description: 2011 TAURUS FWD SELOrdered: 08-AUG- 2010VIN Assigned:VIN#:Scheduled:In Production:Produced:Invoiced:Released:Shipped:Ready:Tax Location: STATE OF MICHIGAN (20 )State Insured:USOB Status:050 - CLEAN UNSCHEDULED ORDER
As i pasted the string in notepad++ it shows like this.
Upvotes: 5
Views: 9136
Reputation: 36591
I wrote a program with some help from google and SO.
this program will print the ascii value and the position of character which is non-printable character.
class Program
{
static void Main(string[] args)
{
string text = @"I am an FMCC employee located in the Chicagoland area that currently has 2 available/active ManagementLease tags (non-incremental) and 1 currently utilized Sales Vehicle tag. I have a 2009 Sales vehicle now andhave ordered a replacement for that vehicle (2010 Taurus) per our current direction. I have not had a 2009 Model vehicle for either of my Management Lease tags in 2009. I was married in August of this year andordered a 2010 Flex on one of my Management Lease tags in September.My issue is that my wife's current vehicle is no longer serviceable, and the 2010 Flex has yet to be scheduled tobe built.My exception request is that I be allowed to take delivery and assume payments for a 2010 Taurus that is at alocal dealership and displayed on the ""Vehicles Available Now"" page on an interim basis until my 2010 Flex isdelivered. I appreciate that typically an employee cannot have two vehicles from the same model year on agiven Management Lease tag, but I was hoping an exception could be made due to my recent marriage andthe fact that I did not have a 2009 model year vehicle on any tags.";
for (int i = 0; i < text.Length; i++)
{
if (Char.ConvertToUtf32(text, i) < 32)
{
Console.WriteLine( "position " + i + " " + text[i] + " => " + Char.ConvertToUtf32(text, i));
}
}
Console.ReadLine();
}
}
Upvotes: 0
Reputation: 178630
You can use char.IsControl(c)
to test whether a character is a control (non-printable) character or not:
foreach (var c in str)
{
if (char.IsControl(c))
{
Console.WriteLine("Found control character: {0}", (int)c);
}
}
Upvotes: 10