KalleB Posted December 21, 2008 Share Posted December 21, 2008 $string = Chr(178) $isD = "String is Digit: " & StringIsDigit($string) & @CRLF $isAN = "String is AlNum: " & StringIsAlNum($string) & @CRLF $isXD = "String is XDigit: " & StringIsXDigit($string) MsgBox(0, $string, $isD & $isAN & $isXD)Results in:String is Digit: 1String is AlNum: 1String is XDigit: 0(Human) logic leads me to think that "Digit" is a subset of "XDigit". Why is this not the case?Yes, I have searched the forum and found a statement that these "StringIs"-functions are straightforward C-functions, but I could not find any info on why AutoIT has accepted this behaviour.And, maybe more importantly: If I have a file of arbitrary length, and arbitrary formatting, how do I best sort out numbers of a given length?"345" should be a three character match, but not "A15" or "²98" ("Chr(178)98"). Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 21, 2008 Moderators Share Posted December 21, 2008 XDigit is a misleading name. XDigit validates whether the string has valid "Hex" characters in it only. 0-9 and A-F. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
KalleB Posted December 21, 2008 Author Share Posted December 21, 2008 Yes, but why doesn't Digit do the same (except the A-F part)? Why is ² a 2 in one case but not the other? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 21, 2008 Moderators Share Posted December 21, 2008 Yes, but why doesn't Digit do the same (except the A-F part)? Why is ² a 2 in one case but not the other?Local $s_digit_chars = "" For $i = 0 To 255 If StringIsDigit(Chr($i)) Then $s_digit_chars &= "Dec = " & StringFormat("%02s", $i) & " | Char = " & Chr($i) & @CRLF EndIf Next MsgBox(64, "Info", "All digit characters:" & @CRLF & $s_digit_chars) That might show you better. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
KalleB Posted December 21, 2008 Author Share Posted December 21, 2008 Local $s_digit_chars = "" Local $s_xdigit_chars = "" For $i = 0 To 255 If StringIsDigit(Chr($i)) Then $s_digit_chars &= "Dec = " & StringFormat("%02s", $i) & " | Char = " & Chr($i) & @CRLF EndIf If StringIsXDigit(Chr($i)) Then $s_xdigit_chars &= "Dec = " & StringFormat("%02s", $i) & " | Char = " & Chr($i) & @CRLF EndIf Next No, it does nothing to show why $s_digit_chars is not a subset of $s_xdigit_chars, which is what one would expect. Nor to show why the three superscripts are considered digits at all. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 21, 2008 Moderators Share Posted December 21, 2008 Local $s_digit_chars = "" Local $s_xdigit_chars = "" For $i = 0 To 255 If StringIsDigit(Chr($i)) Then $s_digit_chars &= "Dec = " & StringFormat("%02s", $i) & " | Char = " & Chr($i) & @CRLF EndIf If StringIsXDigit(Chr($i)) Then $s_xdigit_chars &= "Dec = " & StringFormat("%02s", $i) & " | Char = " & Chr($i) & @CRLF EndIf Next No, it does nothing to show why $s_digit_chars is not a subset of $s_xdigit_chars, which is what one would expect. Nor to show why the three superscripts are considered digits at all.I don't understand what you're asking then. Unless you honestly think that chars 177 - 179 are actually values 1 through 3. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
cppman Posted December 21, 2008 Share Posted December 21, 2008 I don't believe superscripts should be considered a digit (and hence why the superscript doesn't show up as a hexadecimal digit). A digit should only be considered to be the numbers 0-9 (as the c-standard library specifies). Miva OS Project Link to comment Share on other sites More sharing options...
GEOSoft Posted December 21, 2008 Share Posted December 21, 2008 I don't understand what you're asking then. Unless you honestly think that chars 177 - 179 are actually values 1 through 3.I think thats the problem Sm0keThey are not digits. Even though they look like a superscripted digit they are actually special characters in the extended set. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
KalleB Posted December 21, 2008 Author Share Posted December 21, 2008 (edited) No, I don't think they (185, 178, 179 ) are digits. But they ARE treated differently when used in StringIsDigit (where the answer is YES) from when used in StringIsXDigit (where the answer is NO).My opinion is that everything that is:either a digit;or the letters A through F (a through f)should be considered an xdigit. This is NOT the case. AutoIT treats the superscripts as digits but not as xdigits.As it is, you need to use for example "IF StringIsDigit($char) AND StringIsXDigit($char)" to get what you expect from "IF StringIsDigit($char)". I was curious as to WHY this is.And I also wanted to know if there is a better way to make sure that a given character is indeed a digit. Edited December 21, 2008 by KalleB Link to comment Share on other sites More sharing options...
cppman Posted December 21, 2008 Share Posted December 21, 2008 And I also wanted to know if there is a better way to make sure that a given character is indeed a digit.For now, you could just use your own. Func IsDigit($char) Local $nVal = Asc($char) return ( ($nVal >= 48) and ($nVal <= 57) ) EndFunc Miva OS Project Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 21, 2008 Moderators Share Posted December 21, 2008 Could always use RegEx: If StringRegExp($s_string, "[0-9]") Then Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
GEOSoft Posted December 21, 2008 Share Posted December 21, 2008 (edited) Could always use RegEx: If StringRegExp($s_string, "[0-9]") ThenWhat would be the difference between that and If StringRegExp($sString, "\d") Then ..... Just curious if it would be different result and I'm not testing it right now. EDIT. NM, I tested and 0 difference. Edited December 21, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
KalleB Posted December 21, 2008 Author Share Posted December 21, 2008 Interestingly enough, "If StringRegExp($sString, "\d")" does not consider ¹²³ to be digits. I guess I have to start learning regex, thanks for that. And until I get a better explanation I'll just presume that the underlying reason for the StringIsDigit issue, I'll believe it's a conspiracy to make sure everyone learns regex. Link to comment Share on other sites More sharing options...
GEOSoft Posted December 21, 2008 Share Posted December 21, 2008 Interestingly enough, "If StringRegExp($sString, "\d")" does not consider ¹²³ to be digits.I guess I have to start learning regex, thanks for that. And until I get a better explanation I'll just presume that the underlying reason for the StringIsDigit issue, I'll believe it's a conspiracy to make sure everyone learns regex.Thats what it is. We want to make sure that everyone learns RegExp.Only Decimal 49 through 57 should be considered digits. And only 65 through 90 and 97 through 122 should be considered as Alpha. Any of these are considered AlNum (Alpha-numeric) and Decimal 0 through 127 will pass the StringIsAscii() Test. None of the superscripted numbers should pass any of those tests.The superscripted numbers are not in the standard ASCII set, they are in the Extended set.As a matter of fact if you changed that regexp to "\w" (any word character which includes a-z, A-Z, 0-9 and spaces) it will still return 0 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Developers Jos Posted December 21, 2008 Developers Share Posted December 21, 2008 (edited) Agree it is strange that StringIsDigit() returns 1 because you would then expect the Number() would return a proper value: $1 = Chr(185) ConsoleWrite('$1 = ' & $1 & @crlf ) ConsoleWrite('StringIsDigit($1) = ' & StringIsDigit($1) & @crlf ) ConsoleWrite('StringIsxDigit($1) = ' & StringIsxDigit($1) & @crlf ) ConsoleWrite('StringIsInt($1) = ' & StringIsInt($1) & @crlf ) ConsoleWrite('StringIsFloat($1) = ' & StringIsFloat($1) & @crlf ) ConsoleWrite('IsNumber($1) = ' & IsNumber($1) & @crlf ) ConsoleWrite('IsFloat($1) = ' & IsFloat($1) & @crlf ) ConsoleWrite('IsInt($1) = ' & IsInt($1) & @crlf ) ConsoleWrite('Number($1) = ' & Number($1) & @crlf ) Edited December 21, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
GEOSoft Posted December 21, 2008 Share Posted December 21, 2008 Agree it is strange that StringIsDigit() returns 1 because you would then expect the Number() would return a proper value: $1 = Chr(185) ConsoleWrite('$1 = ' & $1 & @crlf ) ConsoleWrite('StringIsDigit($1) = ' & StringIsDigit($1) & @crlf ) ConsoleWrite('StringIsxDigit($1) = ' & StringIsxDigit($1) & @crlf ) ConsoleWrite('StringIsInt($1) = ' & StringIsInt($1) & @crlf ) ConsoleWrite('StringIsFloat($1) = ' & StringIsFloat($1) & @crlf ) ConsoleWrite('IsNumber($1) = ' & IsNumber($1) & @crlf ) ConsoleWrite('IsFloat($1) = ' & IsFloat($1) & @crlf ) ConsoleWrite('IsInt($1) = ' & IsInt($1) & @crlf ) ConsoleWrite('Number($1) = ' & Number($1) & @crlf )I guess it could be a minor bug that we can live with while more major ones are being solved. After all, how often would we have to actually test for that? George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Developers Jos Posted December 21, 2008 Developers Share Posted December 21, 2008 Interesting:This method determines if a Char is a radix-10 digit. This contrasts with the IsNumber method, which determines if a Char is of any numeric Unicode category. Numbers include characters such as fractions, subscripts, superscripts, Roman numerals, currency numerators, encircled numbers, and script-specific digits. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
GEOSoft Posted December 21, 2008 Share Posted December 21, 2008 (edited) Interesting:Good info Jos. That has the potential of throwing a developer or two into a panic. Or at least cause a documentation change. Now let me think for a second about who it would be that would have to do that. Edited December 21, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now