473,807 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3831
(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**@discussio ns.microsoft.co m> wrote in message
news:AD******** *************** ***********@mic rosoft.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**@discussio ns.microsoft.co m> 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.co m>
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.A SCII.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**@discussio ns.microsoft.co m> wrote in message
news:AD******** *************** ***********@mic rosoft.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************ *************** *******@microso ft.com>,
Da**@discussion s.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.IsLetterOr Digit() 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
2961
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 here is that the graphic designer wants a pretty (non-webbable) font on the shaded nav tabs, so I'm reduced to using bitmaps. To make the 4-way rollovers ("current" and "hover" states) work I'm using the standard "rollerblind" technique with a...
0
5808
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 stream into a valid xmltextreader document. I have also converted the document to the simple format without the DTD ( just plain xml file ) and I still get the same error: Illegal characters in path.
14
42436
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 = Array(\, /, :, *, ?, ", <, >, |) If Me.TextBox Contains illegal Then MsgBox "You entered illegal characters. Please try again." Me.TextBox = Null
1
5436
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 open in designer. Illegal characters in path" and the file is instead opened in HTML view. I don't know what application or situation may have caused this error. I looked on the newsgroups and noticed that numerous other people were having this...
0
2110
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 name, username, and password. I then present them with a text field to type in SQL queries, and hand back a nicely-formatted HTML table with the result of their queries. Basically, just a programming exercise to get my feet wet with the Web...
1
3174
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 = System.Windows.Forms.Application.ExecutablePath Response.Write(str); }
3
3026
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 all the latin characters are converted ? character which is a illegal character for file name. If my file name is N° documento per Romà
6
23394
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 characters and display a message, "Illegal Characters not allowed". How do I achieve that in JavaScript? Sorry if it seems too simple as I am kinda weak in programming. Thanks.
2
17825
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 (String args) {
0
9720
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10626
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10112
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.