I can't see why this should be a problem. You said you added <meta charset="UTF-8">
to the HTML file, but did you actually save it using UTF-8 encoding? Some plain text editors default to other character sets like iso-8859-1, so you might have incorrect character codes in there somewhere. If your Javascript is stored in a separate file, make sure that is properly encoded too.
Also bear in mind that character entities like °
won't work in SVG files.
var svg = d3.select("body")
.append("svg")
.attr("width", 400)
.attr("height", 100);
svg.append("text")
.text("Water boils at 100°C")
.attr("x", 20)
.attr("y", 50)
.attr("font-family", "sans-serif")
.attr("font-size", "40px");
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>