Smaxs2001
Smaxs2001

Reputation: 23

VBS encoding for ä ü ö ß

i want to automatically generate Signatures for Outlook. The Problem is that I need ä ö ü ß but the code translates them to ä ö ü ß.

I have tried to find an way to change the encoding but my research didn't find anything.

Set Word = CreateObject("Word.Application")
Set Doc = Word.Documents.Add()

Word.Selection.TypeText "ä ö ü ß"

With Word.EmailOptions.EmailSignature
    .EmailSignatureEntriesAdd "AD Signature", Doc.Range()
    .NewMessageSignature = "AD Signature"
    .ReplyMessageSignature = "AD Signature"
End With

Doc.Saved = True
Word.Quit

Upvotes: 2

Views: 1782

Answers (1)

Tomalak
Tomalak

Reputation: 338336

You have saved your VBS file as UTF-8.

Save it in a single-byte encoding (Microsoft Notepad calls it ANSI, on your PC this most likely amounts to Windows-1252).

Notepad "Save As" Dialog

Saving it as UTF-16 also works if you need Unicode characters.

The default encoding in Notepad used to be ANSI since time immemorial, but Windows 10 switched it to plain UTF-8 (without BOM) at some point. This is generally not bad, but the VBScript parser will continue to assume ANSI source code when no BOM is present at the start of the file.

VBScript can handle Unicode sources, but the way to make it aware is the BOM. With UTF-16 a BOM is mandatory, so UTF-16 works.

However, VBScript cannot handle UTF-8 encoded sources, so that won't work even if you chose "UTF-8 with BOM" when saving the file.

Upvotes: 3

Related Questions