LvZito Posted March 29, 2015 at 11:55 AM Report Share #580429 Posted March 29, 2015 at 11:55 AM Olá a todos, Estou a tentar criar um ficheiro em HTML a partir do VB com este código, simplificado para ser mais fácil perceber o problema: Dim MyStream As New IO.FileStream(sAppPAth & "\report.html", IO.FileMode.Create) Dim MyWriter As New IO.StreamWriter(MyStream) Dim HTML_File As String HTML_File = "" HTML_File += "<html>" HTML_File += "<head>" HTML_File += "<title>Report</title>" HTML_File += "<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 > " HTML_File += "</head>" HTML_File += "<body>" HTML_File += "<p> Comentário: João JOÃO </p>" 'close page HTML_File += "</body>" HTML_File += "</html>" MyWriter.Write(HTML_File) MyWriter.Close() MyStream.Close() Try Dim StartInfo As New ProcessStartInfo StartInfo.FileName = "iexplore.exe" StartInfo.Arguments = "file:" + sAppPAth + "\report.html" StartInfo.WindowStyle = ProcessWindowStyle.Maximized StartInfo.UseShellExecute = True System.Diagnostics.Process.Start(StartInfo) Catch ex As Exception MsgBox(ex.Source + " : " + ex.Message) End Try : O ficheiro é criado sem erros mas os caracteres com acentos aparecem com caracteres estranhos (em vez de áã e Ã). Alguém tem alguma sugestão? Obrigado pela ajuda, LvZito Nota: O meu windows está em inglês, tal como o Visual Studio, mas a «culture» está como «pt-PT» Link to comment Share on other sites More sharing options...
nelsonr Posted March 29, 2015 at 08:47 PM Report Share #580448 Posted March 29, 2015 at 08:47 PM Boas, um dos construtures da classe SteamWriter permite definires o encoding. https://msdn.microsoft.com/en-us/library/3aadshsx%28v=vs.110%29.aspx Experimenta passar por exemplo o UTF8. Dim MyWriter As New IO.StreamWriter(MyStream, Encoding.UTF8) Link to comment Share on other sites More sharing options...
informaster Posted March 29, 2015 at 10:00 PM Report Share #580457 Posted March 29, 2015 at 10:00 PM Boa noite para utilizar os caracteres bem tem que formatar primeiro o tipo de letra pode usar formatação em Html por exemplo utf8. Nuno Revez @informaster Link to comment Share on other sites More sharing options...
LvZito Posted March 30, 2015 at 09:23 AM Author Report Share #580468 Posted March 30, 2015 at 09:23 AM Bom dia Nelsonr, Ficou resolvido com a linha do UTF8 Tive de acrescentar a referência a System.Text, mas é o que precisava. Ficou assim: Dim MyWriter As New IO.StreamWriter(MyStream, System.Text.Encoding.UTF8) Muito obrigado pela ajuda. e obrigado também ao informaster. LvZito Link to comment Share on other sites More sharing options...
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