karthikv / nodefront

A node.js-powered rapid front-end development utility.
http://karthikv.github.com/nodefront
MIT License
246 stars 11 forks source link

Can't i use non-utf8 html file with nodefront's serve command? #37

Closed makotot closed 11 years ago

makotot commented 11 years ago

Charactor code in my project is shift-jis. When i use serve command, nodefront automatically set the charactor code to utf8. Therefore, html is garbled when viewed in browser. Is there any solution?

thanks.

ForbesLindesay commented 11 years ago

Usually you'd set it with <meta charset='utf-8'>. Anything other than utf-8 should probably require a very good reason though. Do you really need characters that can't be represented in utf-8?

makotot commented 11 years ago

I think some chinese characters cannot represent in utf-8, and I have to think about it.

ForbesLindesay commented 11 years ago

I think utf8 aims to have pretty good support for chinese characters.

karthikv commented 11 years ago

Nodefront does default to UTF8 when calling response.write(). Could you provide me with an example file that triggers the issue? That way, I can test to see what's causing the problem and find a solution.

makotot commented 11 years ago

@karthikv

Like the following html, some characters cannot represent in utf-8. Therefore, i cannot use utf-8.

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="Shift-JIS">
</head>
<body>
    <p>髙</p>
    <p>㈱</p>
</body>
</html>

The character "髙" is used in the last name of the japanese. The character "㈱" is a symbol that represents the corporation.

ForbesLindesay commented 11 years ago

Odd that they both display fine here though (since this web-page is utf-8)?

makotot commented 11 years ago

@ForbesLindesay

The reason why they are not garbled is because this web-page's character code is utf-8. If the character code is shift-jis, they are garbled (in chrome browser, 『鬮』 and 『繹ア』).

ForbesLindesay commented 11 years ago

In which case the problem is not that some of your stuff is in utf-8 it's that some of your files are in shift-jis. I'd recommend you simply convert them to utf-8 and use that. You'll find utf-8 has much better support in tooling, web-browsers etc.

makotot commented 11 years ago

My explanation is not so good. Since there is no decision of character code in the project to me, utf-8 is not available.

ForbesLindesay commented 11 years ago

My advice would be to produce a utility to do the conversion into utf-8 and just run that before running nodefront. Nobody should be trying to use legacy text file formats.

makotot commented 11 years ago

Sorry for the late reply. Thank you give me advice.

I have run into situations where I think the problem is probably not related to character code. I will check again.