473,397 Members | 1,949 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,397 software developers and data experts.

illegal characters

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
5 3795
(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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: dingbat | last post by:
I'm writing a "tabbed folder" nav bar. Site standards are graphical prettiness, CSS throughout, valid code, but accesibility is ignored where it conflicts with prettiness. The particular issue...
0
by: MB | last post by:
Hi, I am using a web service to call an asp page on a remote server via System.Net.WebClient . The asp page returns a xml stream persisted from a recordset. I am having problems converting the...
14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
1
by: Steve Grahovac | last post by:
I have been having trouble the last few days opening any ASP.NET web forms in the design view in the designer. Every time I clicked on an aspx file I got a message box with the error "Unable to...
0
by: Robin Munn | last post by:
I'm developing a simple proof-of-concept Web application, more as a personal programming exercise than anything else, that presents the user with a login form where they can type in a database...
1
by: Thomas | last post by:
Hi, I have written a simple web application in asp.net 1.1.4322. following is the code written in Page_Load private void Page_Load(object sender, System.EventArgs e) { string str =...
3
by: =?Utf-8?B?SG9seXNtb2tl?= | last post by:
Hi there, I am having a problem im my webservices method when trying to save a file with latin characters to disk passed through WSE. I have noticed that when trying to read the file name from...
6
by: uicouic | last post by:
I have a textbox named "txtName" and a button (btnSave) on a webform. After I have typed the illegal characters into the textbox and click "Save", I would like the webform to check for those...
2
by: Kamaria | last post by:
I wrote this program to calculate the income tax of a user depending on whether or not they were married: import javax.swing.JOptionPane; public class Income_Tax { public static void main...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.