Darien Posted July 1, 2017 Posted July 1, 2017 (edited) Hello, My Windows is in Portuguese. When I run a DOS command and get a character not found in the English language, it appears incorrectly. For example: $pid = Run ( @ComSpec & " /c netsh interface ipv4 show config" , "" , @SW_HIDE , $STDERR_CHILD + $STDOUT_CHILD ) $resultado = "" $erro = "" While 1 $resultado = $resultado & StdoutRead ( $pid ) $erro = $erro & StderrRead ( $pid ) If @error Then msgbox (0 , "" , $resultado ) WEnd The msgbox command displays the message: But the DOS command "netsh interface ipv4 show config" displays the result below: In the 1st line, for example, is displayed "Configura‡Æo da interface "ConexÆo local"" instead of "Configuração da interface "Conexão local"". Is there a way around this? Edited July 1, 2017 by Darien
jchd Posted July 2, 2017 Posted July 2, 2017 Try this: FileWrite("ÃãÇçÑñÕõ.tmp", "Hello World!") Local $pid = Run(@ComSpec & " /c dir ÃãÇçÑñÕõ.tmp", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $resultado = "" Do $resultado &= StdoutRead($pid) Until @error FileDelete("ÃãÇçÑñÕõ.tmp") MsgBox(0, "", _OemToStr($resultado)) Func _OemToStr($sOEM, $iCodepage = Default) If $iCodepage = Default Then $iCodepage = Int(RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Nls\Codepage", "OEMCP")) Local $tText = DllStructCreate("byte[" & StringLen($sOEM) & "]") DllStructSetData($tText, 1, $sOEM) Local $aResult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $iCodepage, "dword", 0, "struct*", $tText, "int", StringLen($sOEM), _ "ptr", 0, "int", 0) Local $tWstr = DllStructCreate("wchar[" & $aResult[0] & "]") $aResult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $iCodepage, "dword", 0, "struct*", $tText, "int", StringLen($sOEM), _ "struct*", $tWstr, "int", $aResult[0]) Return DllStructGetData($tWstr, 1) EndFunc ;==>_OemToStr 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)
Darien Posted 20 hours ago Author Posted 20 hours ago Hello, Starting with the 24H2 update, the function no longer works. Making the registry changes below makes it work again, but it has a side effect: AutoIt does not correctly read INI files that contain characters in Portuguese, using the IniRead command. Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Nls\CodePage] "ACP"="65001" "OEMCP"="65001" "MACCP"="65001"
ioa747 Posted 17 hours ago Posted 17 hours ago (edited) when you open the ini file in notepad, what does it say in the bottom right? UTF-8 or ANSI? if it says ANSI, save it as UTF-8, and try reading it again with AutoIt Edited 17 hours ago by ioa747 I know that I know nothing
Darien Posted 12 hours ago Author Posted 12 hours ago It is in ANSI format, but I don't want to have to change each file. I would like a simpler solution, such as changing a registry key or changing the _OemToStr function.
ioa747 Posted 11 hours ago Posted 11 hours ago (edited) go to 'Administrative language settings' and look under 'Current language for non-Unicode programs' if it says Portuguese. If it says Portuguese , and even then it doesn't read them correctly, then... I don't know any other solution. except #include <File.au3> #include <Array.au3> Local $aFiles = AllToUTF8(@ScriptDir, "*.ini", 1) Func AllToUTF8($dir, $sMask = "*", $iRecur = $FLTAR_NORECUR) If StringRight($dir, 1) <> "\" Then $dir &= "\" $aList = _FileListToArrayRec($dir, $sMask, 1, $iRecur, $FLTAR_NOSORT, $FLTAR_FULLPATH) If Not IsArray($aList) Then MsgBox($MB_SYSTEMMODAL, "Ooops!", "No .ini files found") Return SetError(1, 0, 0) Else For $i = 1 To $aList[0] Local $sTxt = FileRead($aList[$i]) Local $sNewName, $iN = "" Do $sNewName = StringTrimRight($aList[$i], 4) & ".old" & $iN If FileExists($sNewName) Then $iN += 1 Until Not FileExists($sNewName) FileMove($aList[$i], $sNewName) FileWrite($aList[$i], $sTxt) Next MsgBox($MB_SYSTEMMODAL, "Job Complete!", "All " & $aList[0] & " .ini files converted to UTF-8") EndIf EndFunc ;==>AllToUTF8 Edit: Just keep in mind that with the flag 1 in AllToUTF8(@ScriptDir, "*.ini", 1), it will do the conversion, in all .ini in all subfolders Edited 11 hours ago by ioa747 I know that I know nothing
argumentum Posted 10 hours ago Posted 10 hours ago (edited) Am installing his version and language to see what would work 🤯 Edited 10 hours ago by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted 10 hours ago Posted 10 hours ago 2 hours ago, Darien said: It is in ANSI format, but I don't want to have to change each file. Zip the file so that I can download it in my Portuguese Win11 and see what you see. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted 9 hours ago Posted 9 hours ago (edited) Local $pid = Run(@ComSpec & " /c netsh interface ipv4 show config", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $resultado = "" Do $resultado &= StdoutRead($pid) Until @error MsgBox(0, "", BinaryToString(StringToBinary($resultado, 1), 4)) Exit this worked as expected _OemToStr($sOEM, $iCodepage = 65001) ; also worked just fine. Edited 9 hours ago by argumentum more Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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