Search code examples
cfacebook-graph-apiencodingutf-8locale

What is the locale of UTF-8?


I am getting an XML file from the Facebook API with the data:

<?xml version="1.0" encoding="UTF-8"?> 
<fql_query_response xmlns="api.facebook.com/1.0/"; xmlns:xsi="w3.org/2001/XMLSchema-instance"; list="true"> 
    <user> 
        <uid>100000022063315</uid> 
        <name>0xD7 0x99 0xD7 0x95 0xD7 0x97 0xD7 0x90 0xD7 0x99 0x20 0xD7 0x95 0xD7 0x9B 0xD7 0x98 0xD7 0xA8</name> 
    </user>
</fql_query_response>

I want to translate the UTF-8 to wchar_t. I am trying to do so with mbstowcs but apparently I need to know what locale to set. Is there a standard locale for Facebook? or for UTF-8?


Solution

  • To translate data that's not associated with the user's configured locale, but rather an explicitly specified encoding, you should use iconv, not mbsrtowcs. You don't need setlocale at all for this.