How to escape special characters from a markdown string?

I have a markdown file (utf8) that I am turning into a html file. My current setup is pretty straight forward (pseudo code):

var file = read(site.postLocation + '/in.md', 'utf8');
var escaped = marked( file );
write('out.html', escaped);

This works great, however I've now run into the issue where there are special characters in the markdown file (such as é) that will get messed up when viewed in a browser (é).

I've found a couple of npm modules that can convert html entities, however they all convert just about all convertable characters. Including those required by the markdown syntax (for example '#' becomes '#' and '.' becomes '.' and the markdown parser will fail.

I've tried the libs entities and node-iconv.

I imagine this being a pretty standerd problem. How can I only replace all strange letter characters without all the markdown required symbols?

As pointed out by hilarudeens I forgot to include meta charset html tag.

<meta charset="UTF-8" />

If you come across similar issues, I would suggest you check that first.