core: move charset enum/string conversion to it's own file
This commit is contained in:
@@ -514,54 +514,6 @@ mm_modem_set_charset (MMModem *self,
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
MMModemCharset charset;
|
||||
} CharsetEntry;
|
||||
|
||||
static CharsetEntry charset_map[] = {
|
||||
{ "UTF-8", MM_MODEM_CHARSET_UTF8 },
|
||||
{ "UCS2", MM_MODEM_CHARSET_UCS2 },
|
||||
{ "IRA", MM_MODEM_CHARSET_IRA },
|
||||
{ "GSM", MM_MODEM_CHARSET_GSM },
|
||||
{ "8859-1", MM_MODEM_CHARSET_8859_1 },
|
||||
{ "PCCP437", MM_MODEM_CHARSET_PCCP437 },
|
||||
{ "PCDN", MM_MODEM_CHARSET_PCDN },
|
||||
{ "HEX", MM_MODEM_CHARSET_HEX },
|
||||
{ NULL, MM_MODEM_CHARSET_UNKNOWN }
|
||||
};
|
||||
|
||||
const char *
|
||||
mm_modem_charset_to_string (MMModemCharset charset)
|
||||
{
|
||||
CharsetEntry *iter = &charset_map[0];
|
||||
|
||||
g_return_val_if_fail (charset != MM_MODEM_CHARSET_UNKNOWN, NULL);
|
||||
|
||||
while (iter->name) {
|
||||
if (iter->charset == charset)
|
||||
return iter->name;
|
||||
iter++;
|
||||
}
|
||||
g_warn_if_reached ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MMModemCharset
|
||||
mm_modem_charset_from_string (const char *string)
|
||||
{
|
||||
CharsetEntry *iter = &charset_map[0];
|
||||
|
||||
g_return_val_if_fail (string != NULL, MM_MODEM_CHARSET_UNKNOWN);
|
||||
|
||||
while (iter->name) {
|
||||
if (strcasestr (string, iter->name))
|
||||
return iter->charset;
|
||||
iter++;
|
||||
}
|
||||
return MM_MODEM_CHARSET_UNKNOWN;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
|
Reference in New Issue
Block a user