Skip to content

Commit 55839ae

Browse files
committed
Made the attributes parser adhere to the export encoding conventions.
1 parent 4d7c168 commit 55839ae

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Rubberduck.Parsing/VBA/AttributeParser.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7+
using System.Text;
78
using System.Threading;
89
using Rubberduck.Parsing.PreProcessing;
910
using Rubberduck.Parsing.Symbols.ParsingExceptions;
@@ -37,7 +38,17 @@ public AttributeParser(IModuleExporter exporter, Func<IVBAPreprocessor> preproce
3738
// a document component without any code wouldn't be exported (file would be empty anyway).
3839
return (null, null, new Dictionary<Tuple<string, DeclarationType>, Attributes>());
3940
}
40-
var code = File.ReadAllText(path);
41+
42+
string code;
43+
if (module.ComponentType == ComponentType.Document)
44+
{
45+
code = File.ReadAllText(path, Encoding.UTF8); //We export the code from Documents as UTF8.
46+
}
47+
else
48+
{
49+
code = File.ReadAllText(path, Encoding.Default); //The VBE exports encoded in the current ANSI codepage from the windows settings.
50+
}
51+
4152
try
4253
{
4354
File.Delete(path);

0 commit comments

Comments
 (0)