一个给定的字符串中打印非打印字符?字符串、字符

2023-09-05 04:35:34 作者:借口伪装得再美还是借口

我有一个字符串,在SQL中我测试过这个字符串包含非打印字符,但我无法找到它们的。

I've a string, In sql I've tested this string contains non-printable characters but I couldn't find which are those.

所以,任何人都可以建议我怎么能找到并打印在C#中的非打印字符 通过传递这个字符串?

So can anyone suggest me how can i find and print those non-printable characters in C# by passing this string?

我订的是金牛座在八月和尚未定,我是   只是想知道如果有什么不对的顺序?或者,如果   队列仅仅是多长时间?订单号:8028Vehicle代表:74JTag#:   200L049Description 2011金牛座FWD SELOrdered:08-AUG- 2010VIN   分配:VIN#:定时:   制作:制作:开具发票:发行时间:发货:准备:税   位置:省份Michigan(20)国家保险人:USOB状态:050 -   清洁计划外订单

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.

推荐答案

您可以使用 char.IsControl(C)来测试一个字符是否是一个控制(非可打印)字符或不:

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);
    }
}