一个给定的字符串中打印非打印字符? [英] print non-printable characters in a given string?

查看:255
本文介绍了一个给定的字符串中打印非打印字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串,在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);
    }
}

这篇关于一个给定的字符串中打印非打印字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆