DannyJ Posted April 27, 2021 Posted April 27, 2021 (edited) $String = "áéőúűüóö" ConsoleWrite($String) My initial problem is SciTE unable to recognize the ű and ü and ő characters if I try to make a variable. Here is an other exaple: expandcollapse popup#include-once #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Language=1038 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <WinAPIConv.au3> #Include <WinAPI.au3> #include <WinAPIConv.au3> ;--------END OF INCLUDES--------------------------------- Local Const $SF_ANSI = 1 Local Const $SF_UTF16_LE = 2 Local Const $SF_UTF16_BE = 3 Local Const $SF_UTF8 = 4 $sCommand = "powershell.exe Get-ChildItem" Local $iPid = Run($sCommand, @DesktopDir, @SW_SHOW, $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPid) ConsoleWrite(@CRLF) ConsoleWrite($sOutput) ConsoleWrite(_WinAPI_WideCharToMultiByte($sOutput,2)) ConsoleWrite(_WinAPI_MultiByteToWideChar($sOutput,2)) ConsoleWrite(BinaryToString(StringToBinary($sOutput, $SF_ANSI), $SF_UTF8)) ConsoleWrite(StringToBinary($sOutput, $SF_UTF8)) $aLang = StringRegExp($sOutput, "(*UCP)(\p{Latin}+(?:\s+\p{Latin}+)*)", 1) ConsoleWrite($aLang) In this script, I use Get-ChildItem to list the files and directories to the console, but if I the direcoty or file contains ű or ő or ü or ó etc. then it write out some strange characters. I have read some topic in this forum about this issue, and I have already tried some of the funtions (see above in the script). As you can see I changed the language Directive #AutoIt3Wrapper_Res_Language=1038 to hungarian, which contains these characters. Do you have any idea, how can I set to SciTE to recognize these charachters or how can I read properly from Powershell Console with these accents? Edited May 4, 2021 by DannyJ
Developers Jos Posted April 27, 2021 Developers Posted April 27, 2021 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team 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.
Developers Jos Posted April 27, 2021 Developers Posted April 27, 2021 (edited) 4 minutes ago, DannyJ said: SciTE Guess you mean AutoIt3? Is this a CodePage(Ansi) versus UTF8 (Unicode) issue? Check your File/Encoding setting for the scriptfile. Jos Edited April 27, 2021 by Jos DannyJ 1 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.
DannyJ Posted April 27, 2021 Author Posted April 27, 2021 10 minutes ago, Jos said: Guess you mean AutoIt3? Is this a CodePage(Ansi) versus UTF8 (Unicode) issue? Check your File/Encoding setting for the scriptfile. Jos Thank you for your answer @Jos! Yes I mean AutoIt3. This is a CodePage issue as well. I have already chechked the encoding and it set to UTF 8. (File/Encoding)
Developers Jos Posted April 27, 2021 Developers Posted April 27, 2021 (edited) Try this _ConsoleWrite() UDF in stead of ConsoleWrite() to see if that fixes it for you as it is a known fact that the characters don't display properly: Func _ConsoleWrite($s) ConsoleWrite(BinaryToString(StringToBinary($s, 4), 1)) EndFunc ;==>_ConsoleWrite Jos Edited April 27, 2021 by Jos DannyJ 1 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.
DannyJ Posted April 27, 2021 Author Posted April 27, 2021 (edited) 14 minutes ago, Jos said: Try this _ConsoleWrite() UDF in stead of ConsoleWrite() to see if that fixes it for you as it is a known fact that the characters don't display properly: Func _ConsoleWrite($s) ConsoleWrite(BinaryToString(StringToBinary($s, 4), 1)) EndFunc ;==>_ConsoleWrite Jos Thanks @Jos, I have tried, but unfortunately _ConsoleWrite won't work . If I write out with _ConsoleWrite function. The áé characters represented like:  ‚ The úű represented like: Åű The őö represented like: €¹â€ Edited April 27, 2021 by DannyJ
Nine Posted April 27, 2021 Posted April 27, 2021 Ya, consoleWrite is not the best tool to display unicode strings. Use MsgBox or GUI Label instead. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Developers Jos Posted April 27, 2021 Developers Posted April 27, 2021 30 minutes ago, DannyJ said: unfortunately _ConsoleWrite won't work . It does for me. This simple script: Func _ConsoleWrite($s) ConsoleWrite(BinaryToString(StringToBinary($s, 4), 1)) EndFunc ;==>_ConsoleWrite $test = "áé úű őö " ConsoleWrite($test & @CRLF) _ConsoleWrite($test & @CRLF) Output: 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.
DannyJ Posted April 27, 2021 Author Posted April 27, 2021 13 minutes ago, Nine said: Ya, consoleWrite is not the best tool to display unicode strings. Use MsgBox or GUI Label instead. Thank you very much @Nine Here is my new code snippet: #include-once #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Language=1038 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <WinAPIConv.au3> #Include <WinAPI.au3> #include <WinAPIConv.au3> ;--------END OF INCLUDES--------------------------------- Local Const $SF_ANSI = 1 Local Const $SF_UTF16_LE = 2 Local Const $SF_UTF16_BE = 3 Local Const $SF_UTF8 = 4 $sCommand = "powershell.exe Get-ChildItem" Local $iPid = Run($sCommand, @DesktopDir, @SW_SHOW, $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPid) MsgBox(0,"a", (_WinAPI_WideCharToMultiByte($sOutput,2 ))) MsgBox(0,"a", (_WinAPI_WideCharToMultiByte($sOutput,65000 ))) MsgBox(0,"a", (_WinAPI_WideCharToMultiByte($sOutput,65001 ))) Unfortunately none of them works Do you have any other idea?
Developers Jos Posted April 27, 2021 Developers Posted April 27, 2021 (edited) Please post a script containing the offending characters so we can test with that as your example script obviously doesn't give the same result for us. Edited April 27, 2021 by Jos DannyJ 1 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.
Nine Posted April 27, 2021 Posted April 27, 2021 Oh I see. When getting stream out of DOS console you will need to convert the string into non-DOS characters using _WinAPI_OemToChar ($sStream). Skysnake and argumentum 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
argumentum Posted April 27, 2021 Posted April 27, 2021 1 hour ago, DannyJ said: Here is my new code snippet: #include <AutoItConstants.au3> Test() Func Test() Local $sPath = @TempDir & "\GetChildItemTest" DirCreate($sPath) Local $sFileName = "Test " & Chr(250) & ".txt" ; some characters you'd like to test out ConsoleWrite(@CRLF & '>' & $sFileName & '<' & @CRLF) FileWriteLine($sPath & "\" & $sFileName, "Test") Local $sCommand = "powershell.exe Get-ChildItem -Path " & $sPath Local $iPid = Run($sCommand, @DesktopDir, @SW_SHOW, $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPid) ConsoleWrite($sOutput) ;~ DirRemove($sPath, 1) EndFunc ...better snippet DannyJ 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted April 27, 2021 Posted April 27, 2021 9 minutes ago, Nine said: _WinAPI_OemToChar ($sStream). #include <AutoItConstants.au3> #include <WinAPIConv.au3> Test() Func Test() Local $sPath = @TempDir & "\GetChildItemTest" DirCreate($sPath) Local $sFileName = "Test " & Chr(250) & ".txt" ; some characters you'd like to test out ConsoleWrite(@CRLF & '>' & $sFileName & '<' & @CRLF) FileWriteLine($sPath & "\" & $sFileName, "Test") Local $sCommand = "powershell.exe Get-ChildItem -Path " & $sPath Local $iPid = Run($sCommand, @DesktopDir, @SW_SHOW, $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPid) ConsoleWrite(_WinAPI_OemToChar($sOutput)) ; @nine's solution ;~ DirRemove($sPath, 1) EndFunc DannyJ 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
DannyJ Posted May 4, 2021 Author Posted May 4, 2021 @Jos Thank you very much your help. @Nine and @argumentum than you for your help, your solution with _WinAPI_OemToChar works perfectly. Do you have any idea why I get this error: AutoIt3.exe ended.rc:-1073741819? If I use powershell.exe Get-ChildItem | Format-List Here is a my code: ; Script Start - Add your code below here #include <AutoItConstants.au3> #include <WinAPIConv.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <Array.au3> #include <String.au3> #include <StringConstants.au3> #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion Test() Func Test() ;Local $sCommand = "powershell.exe Get-ChildItem" Local $sCommand = "powershell.exe Get-ChildItem | Format-List " Local $iPid = Run($sCommand, @DesktopDir, @SW_SHOW, $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPid) ; ConsoleWrite(_WinAPI_OemToChar($sOutput)) ; @nine's solution ConsoleWrite($sOutput) _WinAPI_OemToChar($sOutput) ; I get this error if I use | Format-List pipe EndFunc I would be very grateful If you could check my code and run with Get-ChildItem | Format-List, I have no idea why I get the above mentioned error. Ps.: Unfortunately I need Format-List to make array from the command, and I use another commands as well.
argumentum Posted May 4, 2021 Posted May 4, 2021 (edited) know your pipes !?"powershell.exe Get-ChildItem | Format-List" 'powershell.exe "Get-ChildItem | Format-List"' "powershell.exe ""Get-ChildItem | Format-List""" Edited May 4, 2021 by argumentum DannyJ 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
DannyJ Posted May 4, 2021 Author Posted May 4, 2021 Thank you @argumentum I have tried your idea, but unfortunately the console breaks the lines if i call the _WinAPI_OemToChar function. Unf
argumentum Posted May 4, 2021 Posted May 4, 2021 (edited) 29 minutes ago, DannyJ said: I have tried your idea, Is not an idea. Know your pipes !? 29 minutes ago, DannyJ said: unfortunately the console breaks the lines if ... hmmm, that sucks. But you have a 120 char. wide line limit and that sucks too. I was using | Format-Table -Property * I don't have the output you show in the pic., so, could not replicate. No replication = no troubleshooting = no solution Got it. Edited May 4, 2021 by argumentum solved Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted May 4, 2021 Posted May 4, 2021 (edited) ... Local $a = StringSplit($sOutput, @CRLF & @CRLF, 1) For $n = 1 To UBound($a) -1 ;; oops!!! ;; ConsoleWrite(_WinAPI_OemToChar($sOutput & @CRLF)) ; ..guess I'm still sleepy =) If $a[$n] Then ConsoleWrite(_WinAPI_OemToChar($a[$n] & @CRLF & @CRLF)) Next ... Edited May 4, 2021 by argumentum oops Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
DannyJ Posted May 4, 2021 Author Posted May 4, 2021 2 minutes ago, argumentum said: ... Local $a = StringSplit($sOutput, @CRLF & @CRLF, 1) For $n = 1 To UBound($a) -1 ConsoleWrite(_WinAPI_OemToChar($sOutput & @CRLF)) Next ... Thank you, but I get this error: AutoIt3.exe ended.rc:-1073740940
DannyJ Posted May 4, 2021 Author Posted May 4, 2021 Local $a = StringSplit($sOutput, @CRLF & @CRLF, 1) While 1 ConsoleWrite(_WinAPI_OemToChar($sOutput & @CRLF)) WEnd I tried this method still won't work
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