en_US or en-US, which one should you use?

Howard picture Howard · Feb 5, 2011 · Viewed 87k times · Source

Assume you want to store the locale of user preference in database, which value you will use?

en_US or en-US

They are two standards, but which one you prefer to use as part of your own application?

Updated: Is seems many web sites use dash instead of underscore, e.g.

http://zh.wikipedia.org/zh-tw http://www.google.com.hk/search?hl=zh-TW

Answer

Matti Virkkunen picture Matti Virkkunen · Feb 5, 2011

Wait, wait, wait. Guys, I'm pretty sure "-" is the standard. If you see "_" somewhere it's probably something some people came up with to make it a valid identifier.

Personally I'd go with "-", just to be correct.

http://en.wikipedia.org/wiki/IETF_language_tag

http://tools.ietf.org/html/rfc5646