modem-helpers: use new common charset converter when parsing operator name/code
This is the port of commit 4af8483ae4
into the
06-api branch.
This commit is contained in:
@@ -1064,35 +1064,6 @@ mm_gsm_parse_cscs_support_response (const char *reply,
|
|||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
static void
|
|
||||||
convert_operator_from_ucs2 (gchar **operator)
|
|
||||||
{
|
|
||||||
const gchar *p;
|
|
||||||
gchar *converted;
|
|
||||||
gsize len;
|
|
||||||
|
|
||||||
g_return_if_fail (operator != NULL);
|
|
||||||
g_return_if_fail (*operator != NULL);
|
|
||||||
|
|
||||||
p = *operator;
|
|
||||||
len = strlen (p);
|
|
||||||
|
|
||||||
/* Len needs to be a multiple of 4 for UCS2 */
|
|
||||||
if ((len < 4) || ((len % 4) != 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (*p) {
|
|
||||||
if (!isxdigit (*p++))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
converted = mm_modem_charset_hex_to_utf8 (*operator, MM_MODEM_CHARSET_UCS2);
|
|
||||||
if (converted) {
|
|
||||||
g_free (*operator);
|
|
||||||
*operator = converted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
mm_3gpp_parse_operator (const gchar *reply,
|
mm_3gpp_parse_operator (const gchar *reply,
|
||||||
MMModemCharset cur_charset)
|
MMModemCharset cur_charset)
|
||||||
@@ -1123,7 +1094,7 @@ mm_3gpp_parse_operator (const gchar *reply,
|
|||||||
* character set.
|
* character set.
|
||||||
*/
|
*/
|
||||||
if (cur_charset == MM_MODEM_CHARSET_UCS2)
|
if (cur_charset == MM_MODEM_CHARSET_UCS2)
|
||||||
convert_operator_from_ucs2 (&operator);
|
operator = mm_charset_take_and_convert_to_utf8 (operator, MM_MODEM_CHARSET_UCS2);
|
||||||
|
|
||||||
/* Ensure the operator name is valid UTF-8 so that we can send it
|
/* Ensure the operator name is valid UTF-8 so that we can send it
|
||||||
* through D-Bus and such.
|
* through D-Bus and such.
|
||||||
|
Reference in New Issue
Block a user