pb with text encoding...

E

Eric bouxirot

hi,

i have one new probleme...

if i execute one command from command line. (subversion software) i get
some text in french...with accent..

but if i execute the same commande from my code :

Dim myProcess As Process = New Process()
myProcess.StartInfo.FileName = EXEName
myProcess.StartInfo.Arguments = Params
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.StandardOutputEncoding = Text.Encoding.UTF8
myProcess.Start()
myProcess.WaitForExit(30000)
If Not myProcess.HasExited Then
myProcess.Kill()
Else
Dim sOut As StreamReader = myProcess.StandardOutput
ProcOutput = sOut.ReadToEnd()
Endif

i get wrong chars in place of accent chars...

how can i do to get the right encoding ?? (i have try all text.encoding
formats !)

help ! please !
 
E

Eric bouxirot

hi again,

i have found my problem...

here the solution :

Friend Declare Function OemToChar Lib "user32" Alias "OemToCharA"
(ByVal lpszSrc As String, ByVal lpszDst As StringBuilder) As Integer


Private Function ExecuteProcess(ByVal EXEName As String, Optional
ByVal Params As String = "", Optional ByRef ExitCode As Integer = 0,
Optional ByRef ProcOutput As String = "") As Integer
ExecuteProcess = False
Dim myProcess As Process = New Process()
myProcess.StartInfo.FileName = EXEName
myProcess.StartInfo.Arguments = Params
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.StandardOutputEncoding =
System.Text.Encoding.Default
myProcess.Start()
myProcess.WaitForExit(30000)
If Not myProcess.HasExited Then
myProcess.Kill()
Else
Dim strOut As String = myProcess.StandardOutput.ReadToEnd
Dim strBuilder As New StringBuilder(strOut.Length)
OemToChar(strOut, strBuilder)
ProcOutput = strBuilder.ToString
ExitCode = myProcess.ExitCode
ExecuteProcess = True
End If
myProcess.Close()
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top