Skip to content

Commit 4d7c168

Browse files
committed
Made the use of UTF8 for document modules explicit, which bypasses the default encoding heuristic used when reading the exported file.
1 parent 889e915 commit 4d7c168

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Rubberduck.VBEEditor/SafeComWrappers/VBA/VBComponent.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Linq;
4+
using System.Text;
45
using Rubberduck.VBEditor.Extensions;
56
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
67
using Rubberduck.VBEditor.SafeComWrappers.Office.Core.Abstract;
@@ -167,9 +168,9 @@ private void ExportDocumentModule(string path)
167168
if (lineCount > 0)
168169
{
169170
//One cannot reimport document modules as such in the VBE; so we simply export and import the contents of the code pane.
170-
//Because of this, it is OK, and actually preferable, to use the standard UTF8 encoding.
171+
//Because of this, it is OK, and actually preferable, to use the default UTF8 encoding.
171172
var text = CodeModule.GetLines(1, lineCount);
172-
File.WriteAllText(path, text);
173+
File.WriteAllText(path, text, Encoding.UTF8);
173174
}
174175
}
175176

Rubberduck.VBEEditor/SafeComWrappers/VBA/VBComponents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void ImportSourceFile(string path)
123123
var component = this[name];
124124
component.CodeModule.Clear();
125125

126-
var codeString = File.ReadAllText(path);
126+
var codeString = File.ReadAllText(path, Encoding.UTF8);
127127
component.CodeModule.AddFromString(codeString);
128128
}
129129
else if (ext == ComponentTypeExtensions.FormExtension)

0 commit comments

Comments
 (0)