473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

isprint

1.)
I am using C#. Is there any similar function to isprint in C?

2.)
If I trap the event OnKeyDown in a Control, I become a
System.Windows.Forms.KeyEventArgs.
How can I determine whether the key in the KeyEventArgs a printable char is?

Thanks in advance

Jaga
Nov 15 '05 #1
5 9091

I think you'll find that Char.IsControl() will do what you're after.

public static void Main() {
char c = '\t'; \\ Tab character

Console.WriteLine(Char.IsControl(c));
}
"Jaga" <ja***@web.de> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
1.)
I am using C#. Is there any similar function to isprint in C?

2.)
If I trap the event OnKeyDown in a Control, I become a
System.Windows.Forms.KeyEventArgs.
How can I determine whether the key in the KeyEventArgs a printable char is?
Thanks in advance

Jaga

Nov 15 '05 #2

You could also use the Char.GetUnicodeCategory function();

public static void Main() {
char c = '\t';

Console.WriteLine("Character is printable: {0}",
Char.GetUnicodeCategory(c) != UnicodeCategory.Control);
}
"Jaga" <ja***@web.de> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
1.)
I am using C#. Is there any similar function to isprint in C?

2.)
If I trap the event OnKeyDown in a Control, I become a
System.Windows.Forms.KeyEventArgs.
How can I determine whether the key in the KeyEventArgs a printable char is?
Thanks in advance

Jaga

Nov 15 '05 #3
Thank you Ed.
It means all the character, which is NOT IsControl is a printable
character?

I 'd like to test it. Does anybody knows how can I convert
System.WindowsForms.Keys.Left in a char?

Thanks

Jaga


"Ed Courtenay" <re*****************************@edcourtenay.co.uk > schrieb
im Newsbeitrag news:uI**************@TK2MSFTNGP09.phx.gbl...

You could also use the Char.GetUnicodeCategory function();

public static void Main() {
char c = '\t';

Console.WriteLine("Character is printable: {0}",
Char.GetUnicodeCategory(c) != UnicodeCategory.Control);
}
"Jaga" <ja***@web.de> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
1.)
I am using C#. Is there any similar function to isprint in C?

2.)
If I trap the event OnKeyDown in a Control, I become a
System.Windows.Forms.KeyEventArgs.
How can I determine whether the key in the KeyEventArgs a printable char

is?

Thanks in advance

Jaga


Nov 15 '05 #4
Jaga,

This keystroke does not produce a character at all - I am pretty sure the
KeyPress event either is not raised for this keystroke, or the Char property
value in the passed KeyPressedEventArgs instance does not contain a valid
value.

To summarize, you should distinguish characters and keystrokes. Not every
keystroke can produce a character, and not every Unicode character can be
produced by a keystroke given current keyboard layout and input locale
(except for tricks like Alt followed by digit keys on the numeric
("calculator-layout") keyboard pad).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jaga" <ja***@web.de> wrote in message
news:OQ**************@TK2MSFTNGP09.phx.gbl...
Thank you Ed.
It means all the character, which is NOT IsControl is a printable
character?

I 'd like to test it. Does anybody knows how can I convert
System.WindowsForms.Keys.Left in a char?

Thanks

Jaga


"Ed Courtenay" <re*****************************@edcourtenay.co.uk > schrieb
im Newsbeitrag news:uI**************@TK2MSFTNGP09.phx.gbl...

You could also use the Char.GetUnicodeCategory function();

public static void Main() {
char c = '\t';

Console.WriteLine("Character is printable: {0}",
Char.GetUnicodeCategory(c) != UnicodeCategory.Control);
}
"Jaga" <ja***@web.de> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
1.)
I am using C#. Is there any similar function to isprint in C?

2.)
If I trap the event OnKeyDown in a Control, I become a
System.Windows.Forms.KeyEventArgs.
How can I determine whether the key in the KeyEventArgs a printable
char is?

Thanks in advance

Jaga




Nov 15 '05 #5
Thank you Dmitriy.
You are right, the KeyPress event is raised only if the keystroke a
printable character ist.
But it is too late for me. I must already trap the event KeyDown or the
PreProcessMessage.
How can I determine whether the key in the KeyEventArgs of the KeyDown event
a printable char is? The framework can do it, it raises the KeyPress event
only for such characters.
Jaga

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> schrieb
im Newsbeitrag news:er**************@TK2MSFTNGP09.phx.gbl...
Jaga,

This keystroke does not produce a character at all - I am pretty sure the
KeyPress event either is not raised for this keystroke, or the Char property value in the passed KeyPressedEventArgs instance does not contain a valid
value.

To summarize, you should distinguish characters and keystrokes. Not every
keystroke can produce a character, and not every Unicode character can be
produced by a keystroke given current keyboard layout and input locale
(except for tricks like Alt followed by digit keys on the numeric
("calculator-layout") keyboard pad).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jaga" <ja***@web.de> wrote in message
news:OQ**************@TK2MSFTNGP09.phx.gbl...
Thank you Ed.
It means all the character, which is NOT IsControl is a printable
character?

I 'd like to test it. Does anybody knows how can I convert
System.WindowsForms.Keys.Left in a char?

Thanks

Jaga


"Ed Courtenay" <re*****************************@edcourtenay.co.uk > schrieb
im Newsbeitrag news:uI**************@TK2MSFTNGP09.phx.gbl...

You could also use the Char.GetUnicodeCategory function();

public static void Main() {
char c = '\t';

Console.WriteLine("Character is printable: {0}",
Char.GetUnicodeCategory(c) != UnicodeCategory.Control);
}
"Jaga" <ja***@web.de> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
> 1.)
> I am using C#. Is there any similar function to isprint in C?
>
> 2.)
> If I trap the event OnKeyDown in a Control, I become a
> System.Windows.Forms.KeyEventArgs.
> How can I determine whether the key in the KeyEventArgs a printable

char is?
>
> Thanks in advance
>
> Jaga
>
>


Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ian Chard | last post by:
Hi, I need to be able to tell if a character in the ISO-8859-15 codeset (i.e. 8-bit ASCII, incorporating things like accented 'a' or euro currency symbol) is printable. Ordinarily I'd use...
28
by: Christopher Benson-Manica | last post by:
(I did not write this code!) const char *GetSortMethod( unsigned int sortMeth ) { const char *sortingstring; if( sortMeth == 0 ) { sortingstring = "D"; } if( sortMeth == 1 ) { sortingstring...
2
by: SunRise | last post by:
Hi I am creating a C Program , to extract only-Printable-characters from a file ( any type of file) and display them. OS: Windows-XP Ple help me to fix the Errors & Warnings and explain...
9
by: Xian | last post by:
Is there a right and proper (tm) way to end a line? Thinking about portability and the mess that the 'wrong' line endings can cause. E.g. std::cout << "Hello World!\n"; or std::cout << "Hello...
17
by: arnuld | last post by:
solution runs fine but i was not able to do the "hexadecimal" part . any help on that ? --------- PROGRAMME --------------- /* TC++PL 3e, 4.11 exercise 4 STATEMENT: write a programme that...
24
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
33
by: Michael B Allen | last post by:
Hello, Early on I decided that all text (what most people call "strings" ) in my code would be unsigned char *. The reasoning is that the elements of these arrays are decidedly not signed. In...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.