Connecting Tech Pros Worldwide Forums | Help | Site Map

String to Integer Value

Andy
Guest
 
Posts: n/a
#1: Nov 17 '05
I need to check if a character falls within the range of 32 - 127 and 160 -
255. How do I convert a character to the value to make sure it falls within
this acceptable range?

Martin Honnen
Guest
 
Posts: n/a
#2: Nov 17 '05

re: String to Integer Value




Andy wrote:
[color=blue]
> I need to check if a character falls within the range of 32 - 127 and 160 -
> 255. How do I convert a character to the value to make sure it falls within
> this acceptable range?[/color]

If you have a character you can easily get the Unicode codepoint number:

char c = 'a';
int codePoint = c;


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Richard Blewett [DevelopMentor]
Guest
 
Posts: n/a
#3: Nov 17 '05

re: String to Integer Value


"Andy" <Andy@discussions.microsoft.com> wrote in message
news:688D877A-5A69-44D0-A194-664856F86DA3@microsoft.com...[color=blue]
>I need to check if a character falls within the range of 32 - 127 and 160 -
> 255. How do I convert a character to the value to make sure it falls
> within
> this acceptable range?[/color]

int i = int.Parse(myString);

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Mark Rae
Guest
 
Posts: n/a
#4: Nov 17 '05

re: String to Integer Value


"Andy" <Andy@discussions.microsoft.com> wrote in message
news:688D877A-5A69-44D0-A194-664856F86DA3@microsoft.com...
[color=blue]
>I need to check if a character falls within the range of 32 - 127 and 160 -
> 255. How do I convert a character to the value to make sure it falls
> within
> this acceptable range?[/color]

Sounds like you're looking for the ASCII number of a character, like the old
VB Asc() function...

char strChar = 'A';

int intChar = (int)strChar;


Kai Brinkmann [Microsoft]
Guest
 
Posts: n/a
#5: Nov 17 '05

re: String to Integer Value


Take a look at Int32.Parse
--
Kai Brinkmann [Microsoft]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.

"Andy" <Andy@discussions.microsoft.com> wrote in message
news:688D877A-5A69-44D0-A194-664856F86DA3@microsoft.com...[color=blue]
>I need to check if a character falls within the range of 32 - 127 and 160 -
> 255. How do I convert a character to the value to make sure it falls
> within
> this acceptable range?[/color]


Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#6: Nov 17 '05

re: String to Integer Value


Mark Rae <mark@mark-N-O-S-P-A-M-rae.co.uk> wrote:[color=blue]
> "Andy" <Andy@discussions.microsoft.com> wrote in message
> news:688D877A-5A69-44D0-A194-664856F86DA3@microsoft.com...
>[color=green]
> >I need to check if a character falls within the range of 32 - 127 and 160 -
> > 255. How do I convert a character to the value to make sure it falls
> > within
> > this acceptable range?[/color]
>
> Sounds like you're looking for the ASCII number of a character, like the old
> VB Asc() function...
>
> char strChar = 'A';
>
> int intChar = (int)strChar;[/color]

.... except that values 160-255 aren't within ASCII.

I think he really is after the Unicode value - and the code you gave
does precisely that :)

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Michael S
Guest
 
Posts: n/a
#7: Nov 17 '05

re: String to Integer Value


> int i = int.Parse(myString);

Nah, that's not what the OP is asking for.

Happy Coding
- Michael S


Michael S
Guest
 
Posts: n/a
#8: Nov 17 '05

re: String to Integer Value


> Take a look at Int32.Parse

Don't do that Andy. =)

- Michael S



Closed Thread