Is there a standard posix C function to convert encodings, say from windows-1251 to utf-8 and back?
Yes, it's iconv().
iconv()
References: