Jump to content
dikart7

The problem of StringReplace

Recommended Posts

dikart7

Hello my friends Sorry about my English , Why are not replaced any character to "é"

 

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection(False)
$var = StringReplace("connect,",",","é") ; this worked
MsgBox(0,"",$var) 

$stdoutRead = StringReplace(_CmdResult('netsh mbn show interface'),",","é") ;why not replaced

MsgBox(0,"",$stdoutRead)
Func _CmdResult($Commands)
    Local $Message
Local $DOS = Run(@ComSpec & " /c "&  $Commands , "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($DOS)
$Message = StdoutRead($DOS)
Return $Message
EndFunc

 

Share this post


Link to post
Share on other sites
Jos
3 minutes ago, dikart7 said:

Why are not replaced any character to "é"

Any character or do you mean a COMMA as that is what you have defined in the StringReplace() command?

Jos

  • Like 1

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
dikart7

The problem with the character é

 

Share this post


Link to post
Share on other sites
Jos

Sorry, but that doesn't answer my question. ;) 
what exactly are you trying to accomplish?
what is the exact content of the STDOUT
 

#include <WinAPIFiles.au3>

$stdoutRead = _CmdResult('netsh mbn show interface')
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $stdoutRead = ' & $stdoutRead & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
$stdoutRead = StringReplace($stdoutRead, ",", "é") ;why not replaced
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $stdoutRead = ' & $stdoutRead & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

MsgBox(0, "", $stdoutRead)
Func _CmdResult($Commands)
    Local $Message
    Local $DOS = Run(@ComSpec & " /c " & $Commands, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    ProcessWaitClose($DOS)
    $Message = StdoutRead($DOS)
    Return $Message
EndFunc   ;==>_CmdResult

Jos

  • Like 1

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
dikart7

@@ Debug(4) : $stdoutRead =
Le systŠme dispose d'une interfaceÿ:

    Nom               : Connexion haut d‚bit mobile 13
    Description        : HUAWEI Mobile Connect - 3G Network Card
    GUID               : {DD2C1976-A1DC-43F4-845F-67C6244A4CAA}
    Adresse physique   : 00:1e:10:1f:79:c9
    tat              : pas connect‚
    Type d'appareil        : L'appareil haut d‚bit mobile est amovible.
    Classe cellulaire     : CDMA
    ID de l'appareil          : 802b9a56
    Fabricant       : HUAWEI TECHNOLOGIES CO.
    ModŠle              : EC156
    Version de micrologiciel   : 11.106.33.00.000
    Nom de fournisseur      : CDMA
    Itin‚rance            : pas d'itin‚rance
    Signal             : 70%


>Error code: 0
@@ Debug(6) : $stdoutRead =
Le systŠme dispose d'une interfaceÿ:

    Nom               : Connexion haut d‚bit mobile 13
    Description        : HUAWEI Mobile Connect - 3G Network Card
    GUID               : {DD2C1976-A1DC-43F4-845F-67C6244A4CAA}
    Adresse physique   : 00:1e:10:1f:79:c9
    tat              : pas connect‚
    Type d'appareil        : L'appareil haut d‚bit mobile est amovible.
    Classe cellulaire     : CDMA
    ID de l'appareil          : 802b9a56
    Fabricant       : HUAWEI TECHNOLOGIES CO.
    ModŠle              : EC156
    Version de micrologiciel   : 11.106.33.00.000
    Nom de fournisseur      : CDMA
    Itin‚rance            : pas d'itin‚rance
    Signal             : 70%

 

Share this post


Link to post
Share on other sites
dikart7

Just bring Mobile Broadband information 

Share this post


Link to post
Share on other sites
Jos

This has everything to do with character encoding. I have attached the same script with 2 different StringReplace() statements.
the first doesn't work and the second works and that is because the first one has an ASCII COMMA and the second an UTF8 COMMA.

Give it a try.

Jos

test.au3

  • Like 1

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
dikart7

You're a genius brother, thank you so much for your help 

Share this post


Link to post
Share on other sites
dikart7

Jos another problem I can't copy Comma

Share this post


Link to post
Share on other sites
dikart7

How do you write a UTF8 COMMA 

Share this post


Link to post
Share on other sites
Jos

It actually looks like it is an ASCII highvalue character and not a UTF character. This character has an ASCII 130 value so this should work:

$stdoutRead = StringReplace($stdoutRead, chr(130), "é") ;why not replaced

Jos

  • Like 1

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
dikart7

Thanks again my friend jos

Share this post


Link to post
Share on other sites
jguinch

It should work fine with this :

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection(False)

Local $iPid = Run(@ComSpec & " /c netsh mbn show interface", @SystemDir, "", $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($iPid)
Local $sResult = StdoutRead($iPid)

MsgBox(0, "", _OEMToAnsi($sResult) )



Func _OEMToAnsi($sOEM)
    Local $a_AnsiFName = DllCall('user32.dll', 'Int', 'OemToChar', 'str', $sOEM, 'str', '')
    If @error = 0 Then $sAnsi = $a_AnsiFName[2]
    Return $sAnsi
EndFunc   ;==>_OEMToAnsi

 

  • Like 1

Share this post


Link to post
Share on other sites
dikart7
On 10/03/2017 at 3:00 PM, jguinch said:

It should work fine with this :

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection(False)

Local $iPid = Run(@ComSpec & " /c netsh mbn show interface", @SystemDir, "", $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($iPid)
Local $sResult = StdoutRead($iPid)

MsgBox(0, "", _OEMToAnsi($sResult) )



Func _OEMToAnsi($sOEM)
    Local $a_AnsiFName = DllCall('user32.dll', 'Int', 'OemToChar', 'str', $sOEM, 'str', '')
    If @error = 0 Then $sAnsi = $a_AnsiFName[2]
    Return $sAnsi
EndFunc   ;==>_OEMToAnsi

 

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

×