helpers: rework normalize_operator() to use str_to_utf8()

Instead of blindly assuming that we can take whatever string given as
valid UTF-8, we'll always attempt to convert from the current modem
charset into UTF-8. Before we were doing this for hex-encoded UCS2,
but not for example for GSM-7.

And due to the now applied GSM-7 conversion, the mf627a/mf627b +COPS
parsing unit tests are updated accordingly, because when converting
from an input string that contains byte 0x40 ('@' in UTF-8) as if it
were GSM-7, the 0x40 is taken as character '¡', encoded as 0xc2,0xa1
in UTF-8).
This commit is contained in:
Aleksander Morgado
2021-02-13 16:04:56 +01:00
parent 63fa9eee46
commit 16df1e17e6
5 changed files with 36 additions and 23 deletions

View File

@@ -1067,7 +1067,7 @@ modem_3gpp_load_operator_name_finish (MMIfaceModem3gpp *self,
error))
return NULL;
mm_3gpp_normalize_operator (&operator_name, MM_MODEM_CHARSET_UNKNOWN);
mm_3gpp_normalize_operator (&operator_name, MM_MODEM_CHARSET_UNKNOWN, self);
return operator_name;
}