Remember that on startup of the main program, the "C" locale is selected as default. You probably don't want this if you handle utf-8.
Calling setlocale(LC_CTYPE, "") turns off this default, and you get whatever is defined in the environment (presumably a utf-8 locale).