The problem is with ’ (i.e. ’) and ” (i.e. ”), which are encoded as ’ and ”, respectively.
See this test case
UPDATE: It seems that the issue is specific to the Html5Entities class. When I repeated the test using require('html-entities').Html4Entities, the encoding worked (see updated test case above).