Article View: borland.public.jbuilder.java.language
Article #8292Re: Check for *all* alphanumeric characters...
From: Valentino Kyriakides
Date: Fri, 06 Apr 2001 10:32
Date: Fri, 06 Apr 2001 10:32
85 lines
3296 bytes
3296 bytes
Torsten, is this character set dependend on the used locale?
I mean, if I need now only specific ranges from such an sort of extended
ASCII character set, so that I allow only specific characters ranges from
the whole [0,256], can I be shure that 0x26 till 0x2F always really include
the charcters "& � ( ) * + , - . /"?
We use the DE local and now we have for some sort of server side input
validition (shop input fields) to allow only certain alphanumeric chars, as:
Numeric: [0x30, 0x39]
Range1: [0x26, 0x2F]
Range2: [0x41, 0x5A] (A-Z)
Range3: [0x61, 0x7A] (a-z)
...
...
Would these always be unique independently of the the local, I don't think
so? And what's if the local doesn't change and is always unique?
Valentino
"Torsten Welches" <torsten.welches@who.cares.netcologne.de> schrieb im
Newsbeitrag news:3acc873c$1_1@dnews...
>
> Valentino,
>
> isASCII would be simply:
>
> public static boolean isASCII(String s) {
> char[] chars = s.toCharArray();
> for (int i = 0; i < chars.length; i++) {
> if (chars[i] > 0xFF) {
> return false;
> }
> }
> return true;
> }
>
> Torsten
>
> "Valentino Kyriakides" <vkyr@ision.net> wrote:
> >Hi,
> >
> >the following code fragment shows a simple alphanumeric character check
> >method, which checks if any char inside a passed string is
alphanumeric. -
> >Java's "isLetterOrDigit(char)" method's behaviour from the string class
> >seems not to include whitespaces, punctuation chars like ".", the "@"
sign
> >and german umlauts (�������) etc.
> >
> >Isn't there some equivalent method available which provides something
> >similar to "isASCII", which looks for all chars from ...say... the
extended
> >ASCII charater set or unicode set, so that all above mentioned chars will
be
> >recognized?
> >
> >.....
> > // check for a string only containing alphanumeric characters
> > private boolean check_alphanumeric (String inputField)
> > {
> > char array[] = inputField.toCharArray();
> > Character chr = new Character(' ');
> > int i = 0;
> >
> > while (i < inputField.length()) {
> > if (!chr.isLetterOrDigit (array[i]))
> > return false;
> > i++;
> > }
> > return true;
> > }
> >....
> >....
> >
> >Valentino
> >
> >
>
Technical Details
Message-ID:
<3acd9c04_1@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!fu-berlin.de!news.boerde.de!dnewsReferences:
<3acb4854_2@dnews> <3acc873c$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f74b3,6f88753f3998c69d X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-04-06 03:42:41 PST From: "Valentino Kyriakides" <vkyr@nospamlavielle.com> Newsgroups: borland.public.jbuilder.java.language References: <3acb4854_2@dnews> <3acc873c$1_1@dnews> Subject: Re: Check for *all* alphanumeric characters... Date: Fri, 6 Apr 2001 12:32:52 +0200 Lines: 87 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 194.64.62.36 Message-ID: <3acd9c04_1@dnews> X-Trace: dnews 986553348 194.64.62.36 (6 Apr 2001 03:35:48 -0700) Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!fu-berlin.de!news.boerde.de!dnews