im trying to find this but it seems that i have no such option.
i need to test if a string is a number or a letter, lower or upper case for the latter.
scripted solution is painfully slow, even with an optimzed code thats probability-aware.
any ideas please?
number, letter, upper or lower?
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: number, letter, upper or lower?
See asc() command and google for ascii table.CodeLobster wrote:im trying to find this but it seems that i have no such option.
i need to test if a string is a number or a letter, lower or upper case for the latter.
scripted solution is painfully slow, even with an optimzed code thats probability-aware.
any ideas please?
-
CodeLobster
Re: number, letter, upper or lower?
wouldnt it be the same as declaring each letter or number on a table?Stefan wrote:See asc() command and google for ascii table.CodeLobster wrote:im trying to find this but it seems that i have no such option.
i need to test if a string is a number or a letter, lower or upper case for the latter.
scripted solution is painfully slow, even with an optimzed code thats probability-aware.
any ideas please?
as i can foresee this would be even slower than what i already do which is listing chars
on tables for char-by-char comparison.
diacritic'ed letters fall into the not a number nor a letter category unless i
list them on respective tables by the way.
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: number, letter, upper or lower?
diacritic letters have an number too, but you didn't find them on an ascci table.
I would do what you want like this:
Code: Select all
msg asc("â"); msg asc("è");
$i=200; $arr=""; while($i < 240){ $arr = $arr . chr($i) . "<crlf>"; $i++;} text $arr;I would do what you want like this:
Code: Select all
//48=0, 49=1, 50=2,... 57=9
$token = "3";
$asc = asc($token); msg $asc;
if ( $asc > 47 && $asc < 58){ msg "it is an digit";}else{ msg "not an digit";}
//51
//"it is an digit"
$token = "x";
$asc = asc($token); msg $asc;
if ( $asc > 47 && $asc < 58){ msg "it is an digit";}else{ msg "not an digit";}
//120
//"not an digit"
-
CodeLobster
Re: number, letter, upper or lower?
would you mind in elaborating your test over diacritics a bit more, stefan?
it seems it will scan systems codepage am i right?
it seems it will scan systems codepage am i right?
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: number, letter, upper or lower?
Your system use an codepage to translate keyboard scancodes (for an key) to an glyph,CodeLobster wrote:would you mind in elaborating your test over diacritics a bit more, stefan?
it seems it will scan systems codepage am i right?
in the paste there was only 7 bit codepage = 128 signs (ASCII), then there was an extended 8-bit table (256 signs) (extended ascii)
now there are unicode codepage which can hold thousands of different items.
But the base, the first 128 signs are still the same as the old standard ascii table.
The decimal code 48 till 57 stands for digits 0 till 9 (48=0, 49=1, 50=2,... 57=9)
65 till 90 are A-Z
97 till 122 are a-z
What else digits are from interest for you depends on your used codepage.
See your start menu > programs > accessories > system apps > code table (or smtg like that)
Or use this code to see the mapping digit<>glyph
Code: Select all
$i=33; $arr="";
while($i < 1640){ $arr = $arr . "$i=" . chr($i) . "<crlf>"; $i++;} text $arr;Now you can check which signs are from interest for you and use an code to check the asc() of each token of an string to see if it is an digit, an char or an sign.
Wasn't there an command to change diacritics to standard english chars, which could be used firstly?
-
CodeLobster
Re: number, letter, upper or lower?
if you refer to recase, remove diacritics i have to check whether or not it returns operation successful.Stefan wrote: Wasn't there an command to change diacritics to standard english chars, which could be used firstly?
all in all your post was very appreciated and it turned out to be a quicker mean to perform some verifications, have to check now the diacritics, punctuation marks. thank u.
XYplorer Beta Club