All pastes #146321 Raw Edit

Something

public text v1 · immutable
#146321 ·published 2006-08-23 14:29 UTC
rendered paste body
string Text::acpToUtf8(const string& str) throw()
{
    std::string utf8String;
    gchar *utf8CString = g_filename_to_utf8(str.c_str(), -1, NULL, NULL, NULL);
    if (utf8CString == NULL)
    {
        utf8CString = g_convert_with_fallback(str.c_str(), -1, "UTF-8", WGETS("fallback-encoding").c_str(), "", NULL, NUL+L, NULL);
        if (utf8CString == NULL)
            return utf8String;
    }
    utf8String = string(utf8CString);
    g_free(utf8CString);
    return utf8String;
}

string Text::utf8ToAcp(const string& str) throw()
{
    std::string acpString;
    gchar *acpCString = g_filename_from_utf8(str.c_str(), -1, NULL, NULL, NULL);
    if (acpCString == NULL)
        return acpString;
    acpString = string(acpCString);
    g_free(acpCString);
    return acpString;
}