VAN0 Posted May 21, 2022 Share Posted May 21, 2022 Just curious, what's the reasoning behind not supporting Unicode in ConsoleWrite? Spoiler For SciTe output we can use this trick: Func _ConsoleWrite($txt) ConsoleWrite(BinaryToString(StringToBinary($txt, 4), 1)) EndFunc But that seems to me unnecessary hoops we have to jump through... TheDcoder 1 Link to comment Share on other sites More sharing options...
jchd Posted May 22, 2022 Share Posted May 22, 2022 I guess it's for historic reasons. BTW, I use my function CW() instead, which works in compiled programs as well: Func CW($s = "") If @Compiled Then _CUI_ConsoleWrite($s) Else _ConsoleWrite($s) EndIf EndFunc ;==>CW Func _CUI_ConsoleWrite(ByRef $s) Local Static $hDll = DllOpen("kernel32.dll") Local Static $hCon = __CUI_ConsoleInit($hDll) DllCall($hDll, "bool", "WriteConsoleW", "handle", $hCon, "wstr", $s & @LF, "dword", StringLen($s) + 1, "dword*", 0, "ptr", 0) Return EndFunc ;==>_CUI_ConsoleWrite ; internal use only Func __CUI_ConsoleInit(ByRef $hDll) DllCall($hDll, "bool", "AllocConsole") Return DllCall($hDll, "handle", "GetStdHandle", "int", -11)[0] EndFunc ;==>__CUI_ConsoleInit ; Unicode-aware ConsoleWrite Func _ConsoleWrite(ByRef $s) ConsoleWrite(BinaryToString(StringToBinary($s & @LF, 4), 1)) EndFunc ;==>_ConsoleWrite TheDcoder, Musashi, pixelsearch and 1 other 2 2 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...
Skysnake Posted May 23, 2022 Share Posted May 23, 2022 (edited) @jchd How would I get AutoIt to display this? https://www.htmlsymbols.xyz/unicode/U+2705 ;$s = BinaryToString(StringToBinary(0x2705, $SB_UTF8), $SB_UTF8) CW($s) ;Writes 9989 ; the HTML value Please? Edited May 23, 2022 by Skysnake Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
jchd Posted May 23, 2022 Share Posted May 23, 2022 $s = BinaryToString(StringToBinary(ChrW(0x2705), $SB_UTF8), $SB_UTF8) CW($s) Skysnake 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...
Skysnake Posted May 24, 2022 Share Posted May 24, 2022 OK, so my console writes this >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\AutoIt\unicode\write_unicode.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop ✅ +>08:45:57 AutoIt3.exe ended.rc:0 +>08:45:57 AutoIt3Wrapper Finished. >Exit code: 0 Time: 1.032 Now I am guessing that the console output and file EXE may display different results... So (a) should I change the Console output? Or should I just test with display (like in msgbox) My Msgbox displays 0 MsgBox(0,"Unicode",CW($s)) Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
jchd Posted May 24, 2022 Share Posted May 24, 2022 (edited) To display Unicode in the Scite console you need to switch it to UTF8 and select a Unicode-aware display font. I recommend DéjàVu Sans Mono: it's very unambiguous and covers a fair part of Unicode. No available font covers all of Unicode! Edited May 24, 2022 by jchd 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...
Skysnake Posted May 24, 2022 Share Posted May 24, 2022 5 hours ago, jchd said: No available font covers all of Unicode! Thank you. I finally understand what you mean Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
VAN0 Posted October 6 Author Share Posted October 6 How can another program executed by the compiled script change the script's output into proper UTF8 encoding? For example using magick.exe from this package #AutoIt3Wrapper_Change2CUI=y Local $s = ChrW(0x2190) & @LF ConsoleWrite(BinaryToString(StringToBinary("Before " & $s, 4), 1)) Local $iPID = Run("magick.exe", "", @SW_HIDE, 8) If @error Then ConsoleWrite("error") While ProcessExists($iPID) WEnd ConsoleWrite(BinaryToString(StringToBinary("After " & $s, 4), 1)) ; leave window open sleep(5000) I'm getting: Link to comment Share on other sites More sharing options...
jchd Posted October 7 Share Posted October 7 I don't know why. It would take to dig inside the source code to find the answer, or maybe ask on their support forum (if any). None of the win64 versions installs correctly here. 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...
TheDcoder Posted October 7 Share Posted October 7 11 hours ago, VAN0 said: How can another program executed by the compiled script change the script's output into proper UTF8 encoding? Not sure how CMD works but *nix terminals support "terminal codes" which can change the behaviour of the terminal... something like changing the terminal's text interpreter's encoding option EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion 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