By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,678 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,678 IT Pros & Developers. It's quick & easy.

illegal characters

P: n/a
I need to cut out illegal characters in a string submitted from a mobile
phone to a web form. I need a way to check for the illegal characters in a
textbox. I intend to loop through the text and remove the illegal characters.
Is there an equivalent function to c# to chr() in Visual basic? I want the
decimal value of a character, like "A" is 65 in ACII2. If there is a
equilvalent command does it return ACII2 or unicode?

I know there is a chr command in c# but it dosen't do the same thing.
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
(int)'A' will give you 65

so

char temp = 'A';
(int) temp

or

(int)stringVar[x]
--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:AD**********************************@microsof t.com...
I need to cut out illegal characters in a string submitted from a mobile
phone to a web form. I need a way to check for the illegal characters in a
textbox. I intend to loop through the text and remove the illegal characters. Is there an equivalent function to c# to chr() in Visual basic? I want the decimal value of a character, like "A" is 65 in ACII2. If there is a
equilvalent command does it return ACII2 or unicode?

I know there is a chr command in c# but it dosen't do the same thing.

Nov 16 '05 #2

P: n/a
Dave <Da**@discussions.microsoft.com> wrote:
I need to cut out illegal characters in a string submitted from a mobile
phone to a web form. I need a way to check for the illegal characters in a
textbox. I intend to loop through the text and remove the illegal characters.
Is there an equivalent function to c# to chr() in Visual basic? I want the
decimal value of a character, like "A" is 65 in ACII2. If there is a
equilvalent command does it return ACII2 or unicode?

I know there is a chr command in c# but it dosen't do the same thing.


There's no "chr" command (or any commands) in C#. However, you can just
use the unicode value:

int x = 'A'; // x will now be 65

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

P: n/a
C# equivalents of VB functions:

int Asc(char ch)
{
//Return the character value of the given character
return (int)Encoding.ASCII.GetBytes(S)[0];
}

Char Chr(int i)
{
//Return the character of the given character value
return Convert.ToChar(i);
}
There are also some nice builtin methods for string handling in c# such as
Replace(), Split() and Remove().

See docs for more details.

ok,
aq

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:AD**********************************@microsof t.com...
I need to cut out illegal characters in a string submitted from a mobile
phone to a web form. I need a way to check for the illegal characters in a
textbox. I intend to loop through the text and remove the illegal characters. Is there an equivalent function to c# to chr() in Visual basic? I want the decimal value of a character, like "A" is 65 in ACII2. If there is a
equilvalent command does it return ACII2 or unicode?

I know there is a chr command in c# but it dosen't do the same thing.

Nov 16 '05 #4

P: n/a
In article <AD**********************************@microsoft.co m>,
Da**@discussions.microsoft.com says...
I need to cut out illegal characters in a string submitted from a mobile
phone to a web form. I need a way to check for the illegal characters in a
textbox. I intend to loop through the text and remove the illegal characters.
Is there an equivalent function to c# to chr() in Visual basic? I want the
decimal value of a character, like "A" is 65 in ACII2. If there is a
equilvalent command does it return ACII2 or unicode?

I know there is a chr command in c# but it dosen't do the same thing.


In addition to the other answers, you can use regular expressions to
remove the illegal characters.

Sunny
Nov 16 '05 #5

P: n/a
I would suggest you to use Char class'es static methods like Char.IsLetter()
or Char.IsLetterOrDigit() as they take in account the language support. For
example if you run your application in US 'ä' would be an illegal character
but in Denmark it will be OK. Char methods take care of it you you.

"Dave" wrote:
I need to cut out illegal characters in a string submitted from a mobile
phone to a web form. I need a way to check for the illegal characters in a
textbox. I intend to loop through the text and remove the illegal characters.
Is there an equivalent function to c# to chr() in Visual basic? I want the
decimal value of a character, like "A" is 65 in ACII2. If there is a
equilvalent command does it return ACII2 or unicode?

I know there is a chr command in c# but it dosen't do the same thing.

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.