kadirahq / meteor-dochead

Isomorphic way to manipulate document.head for Meteor apps
MIT License
131 stars 17 forks source link

non-English characters get translated differently in title tag #2

Closed awsp closed 9 years ago

awsp commented 9 years ago

I was trying to insert some non-English characters into the title tag, Characters displayed correctly without errors, but in the source code, they get translated into some unrecognized characters. (Looks like some escaped UTF8 characters)

For example,

DocHead.setTitle('タイトル');

Gets translated into this

<title>&#x30BF;&#x30A4;&#x30C8;&#x30EB;</title>

I already put the meta tag with charset set to utf-8, but source code still remains the same see my forked repo: https://github.com/awsp/hello-react-meteorhttps://github.com/awsp/hello-react-meteor/blob/master/both/router.jsx

I would like it to be exactly the same as the title I input. How would I possibly do it?

PS: The body content being processed by the package flow-router-ssr displays non-English characters correctly even in source code. It seems to happen in <head> tag only.

EDIT This issue seems to happen in meta tag as well.

arunoda commented 9 years ago

Yeah! Seems like something to investigate. Let's check.

awsp commented 9 years ago

Thanks for your reply. I found this article might look somewhat similar, hope it helps. http://stackoverflow.com/a/2862421/2167601

To decode, maybe we can use this? http://stackoverflow.com/a/9609450/2167601

But I have no idea how to yet apply to this issue.

awsp commented 9 years ago

Ok, I think I have located where the issue is. It is actually in the flow-router-ssr package, https://github.com/kadirahq/flow-router/blob/ssr/server/route.js#L95

Is it possible to change to the follow? In that case, it would not encode anything in <head> including title and meta.

var $ = Cheerio.load(data, {
  decodeEntities: false
});
arunoda commented 9 years ago

Yeah! I think that's the issue. Could you send me a PR for that project?

awsp commented 9 years ago

thanks!