Problem with charsets in html

2

I needed to apply a centralized automatic signature on a client. What I did was write an HTML with variables NAME POST ADDRESS etc.

Then I copy the files in generic to the team through a GPO and I execute a .vbs that performs the following functions with code quoted:

-Define variables taking the AD data

-Determine this html as an outlook signature

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

objSignatureObject.NewMessageSignature = "Empresa"
objSignatureObject.ReplyMessageSignature = "Empresa"


objDoc.Saved = True
objWord.Quit

Open the html and save it in a string type variable

-Edit the generic fields by the real data of each user with Replace

-Save changes using utf-8 format

Save2File strNewText,appDataLocation+"\Microsoft\firmas\Empresa.html"

Sub Save2File (sText, sFile)
    Dim oStream
    Set oStream = CreateObject("ADODB.Stream")
    With oStream
        .Open
        .CharSet = "utf-8"
        .WriteText sText
        .SaveToFile sFile, 2
    End With
    Set oStream = Nothing
End Sub

So far everything would seem normal, but the body of the html has two components. The firm itself; and a disclaimer with text in Spanish and English that I was asked to add.

The definition of the charset in the html is the following:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

But it turns out that at this moment, only in the disclaimer the accents appear with strange characters, as if the charset did not recognize them.

With some modifications that I made I could invest it, that is to say, the name or the sector in the company of the personnel left me with errors in the ticks, but the disclaimer went well!

I need to unify it, and either in utf-8 or iso-8859-1 to get both AD and disclaimer data displayed correctly with accents and all.

    
asked by Sebastián Labonia 27.07.2016 в 14:59
source

1 answer

1

The problem is not in the charset of the html, the problem is that when windows creates their files they have as default encoding windows-1252. Of course what happens is that the html is waiting for data in utf-8 and they come in windows-1252. Check that when you create the file the encoding is utf-8. To change that coding you can use notepad ++ or any IDE. I hope it helps you. Greetings

    
answered by 27.07.2016 / 18:10
source