mike1950r Posted July 7, 2021 Share Posted July 7, 2021 Hi i want the Asc Number of "ć", which is 262. But with Asc("ć") i get 99 instead, which is the number for "c". It's used in a script, which checks if a string contents any characters above 255. Thanks for assistance. cheers mike Link to comment Share on other sites More sharing options...
Solution Danp2 Posted July 7, 2021 Solution Share Posted July 7, 2021 Have you looked into using AscW() instead of Asc()? mike1950r 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mike1950r Posted July 7, 2021 Author Share Posted July 7, 2021 hi danp2, i have tried without success. cheers mike Link to comment Share on other sites More sharing options...
jchd Posted July 7, 2021 Share Posted July 7, 2021 The Unicode codepoint of ć is 0x107, that is decimal 263, not 262. ConsoleWrite(AscW("ć") & @LF) mike1950r 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
mike1950r Posted July 7, 2021 Author Share Posted July 7, 2021 (edited) thanks jchd, i do it this way, works fine. was my fault. thanks also danp2. cheers mike Edited July 7, 2021 by mike1950r Link to comment Share on other sites More sharing options...
mike1950r Posted July 7, 2021 Author Share Posted July 7, 2021 hi again, is there an existing autoit function or atleast a faster way for this: $bSuccess = True For $i = 1 To StringLen($sString) If ASCW(StringMid($sString, $i, 1)) > 255 Then $bSuccess = False ExitLoop EndIf Next Return $bSuccess in fact "StringIsASCII($sString)" works much faster. thanks for advice cheers mike Link to comment Share on other sites More sharing options...
jchd Posted July 7, 2021 Share Posted July 7, 2021 ; sample Unicode strings in AutoIt encoding (UCS2) Local $a = [ _ "All lower ASCII here!", _ "Some characters ¼½¾ÀÁÇÖæÿ in upper ANSI 1252", _ "Some characters > 0xFF: Μεγάλο πρόβλημα" _ ] For $s In $a ConsoleWrite('"' & $s & '"' & " contains " & (StringRegExp($s, "^[\x00-\x7F]*$") ? "" : "NOT ") & "only lower ASCII" & @LF) ConsoleWrite('"' & $s & '"' & " contains " & (StringRegExp($s, "[\x80-\xFF]") ? "some" : "NO ") & "upper ASCII" & @LF) ConsoleWrite('"' & $s & '"' & " contains " & (StringRegExp($s, "[\x{100}-\x{FFFF}]") ? "" : "NO ") & "characters > 0x100" & @LF) Next mike1950r 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
mike1950r Posted July 7, 2021 Author Share Posted July 7, 2021 hi jchd, thanks lot for the regex. I modified my function with them: Func StringIsANSI($sString) Local $bSuccess, $iLen $bSuccess = False $iLen = StringLen($sString) If $iLen > 0 Then If StringRegExp($sString, "[\x00-\x7F]") Or StringRegExp($sString, "[\x80-\xFF]") Then $bSuccess = True EndIf If StringRegExp($sString, "[\x{100}-\x{FFFF}]") Then $bSuccess = False EndIf EndIf Return $bSuccess EndFunc ;==>StringIsANSI This works now exellent like in notepad. If a string passes this function with success it can be saved with notepad as ANSI. If the string includes for example "Mišel Matičević", it does not pass the function with success and cannot be saved with notepad as ANSI. Thanks lot again. Cheers mike Link to comment Share on other sites More sharing options...
Danp2 Posted July 7, 2021 Share Posted July 7, 2021 @mike1950r You should be able to do it with a single regex -- Func StringIsANSI($sString) Local $bSuccess, $iLen $bSuccess = True $iLen = StringLen($sString) If $iLen And StringRegEx($sString, "[^\x00-\xFF]") Then $bSuccess = False EndIf Return $bSuccess EndFunc ;==>StringIsANSI This returns True for an empty string, but otherwise it should match your earlier code. mike1950r 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mike1950r Posted July 8, 2021 Author Share Posted July 8, 2021 (edited) thanks cheers mike Edited July 8, 2021 by mike1950r 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