Check out the iconv library: man iconv_open. You can convert the utf-8 string to UCS-2 or UCS-4, where the characters are the same size. iconv is also (relatively) portable, not Linux or GNU specific.
If the Glib suggested earlier is available to you (be careful: this is GPLed), then use it as the best way.
source
share