What are you importing from? If you use an import script (or create one using an existing script as a model), usernames will be converted. If you want to do it via the API for some reason, you can look at the code in the import scripts that munges the usernames into something legal.