How to handle Han Unification with user input?

Han Unification was a decision in Unicode that essentially made it so that the rendering of certain characters in Chinese (Traditional and Simplified) and Japanese are dependent on fonts. HTML implements this by setting the lang attribute. What's the best way to decide which language the user really means when they're typing? Is it possible to check based off their IME?