dikart7

The problem of StringReplace

15 posts in this topic

#1 ·  Posted

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



#2 ·  Posted

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

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted

The problem with the character é

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

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

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted

@@ 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

#6 ·  Posted

Just bring Mobile Broadband information 

Share this post


Link to post
Share on other sites

#7 ·  Posted

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

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted

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

Share this post


Link to post
Share on other sites

#9 ·  Posted

Jos another problem I can't copy Comma

Share this post


Link to post
Share on other sites

#11 ·  Posted

How do you write a UTF8 COMMA 

Share this post


Link to post
Share on other sites

#12 ·  Posted

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

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#13 ·  Posted

Thanks again my friend jos

Share this post


Link to post
Share on other sites

#14 ·  Posted

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

 

1 person likes this

Share this post


Link to post
Share on other sites

#15 ·  Posted

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