Jump to content

Characters displayed incorrectly

Recommended Posts




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 )


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 by Darien

Share this post

Link to post
Share on other sites

Try this:

FileWrite("ÃãÇçÑñÕõ.tmp", "Hello World!")
Local $pid = Run(@ComSpec & " /c dir ÃãÇçÑñÕõ.tmp", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $resultado = ""
    $resultado &= StdoutRead($pid)
Until @error
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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post

Link to post
Share on other sites

Thank you!

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now