diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-08-20 11:32:18 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-08-20 18:13:54 +0200 |
commit | 81162df15dc9a409d0979ff8d472a026f31ed883 (patch) | |
tree | fcfe7e5fc2832ec54262f6dbaa86a150fd9d2843 /src/mm-charsets.h | |
parent | eb5443b197464e55c85d7a8af67a28f2088506a3 (diff) |
charsets: refactor coding style
Mostly to use GLib types like gchar or gint, and also to use
G_N_ELEMENTS() instead of custom end of array terminating items.
Diffstat (limited to 'src/mm-charsets.h')
-rw-r--r-- | src/mm-charsets.h | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/mm-charsets.h b/src/mm-charsets.h index e81674c4..c064eef5 100644 --- a/src/mm-charsets.h +++ b/src/mm-charsets.h @@ -31,9 +31,8 @@ typedef enum { MM_MODEM_CHARSET_UTF16 = 0x00000100, } MMModemCharset; -const char *mm_modem_charset_to_string (MMModemCharset charset); - -MMModemCharset mm_modem_charset_from_string (const char *string); +const gchar *mm_modem_charset_to_string (MMModemCharset charset); +MMModemCharset mm_modem_charset_from_string (const gchar *string); /* Append the given string to the given byte array but re-encode it * into the given charset first. The original string is assumed to be @@ -53,34 +52,37 @@ gchar *mm_modem_charset_byte_array_to_utf8 (GByteArray *array, /* Take a string in hex representation ("00430052" or "A4BE11" for example) * and convert it from the given character set to UTF-8. */ -char *mm_modem_charset_hex_to_utf8 (const char *src, MMModemCharset charset); +gchar *mm_modem_charset_hex_to_utf8 (const gchar *src, + MMModemCharset charset); /* Take a string in UTF-8 and convert it to the given charset in hex * representation. */ -char *mm_modem_charset_utf8_to_hex (const char *src, MMModemCharset charset); - -guint8 *mm_charset_utf8_to_unpacked_gsm (const char *utf8, guint32 *out_len); +gchar *mm_modem_charset_utf8_to_hex (const gchar *src, + MMModemCharset charset); -guint8 *mm_charset_gsm_unpacked_to_utf8 (const guint8 *gsm, guint32 len); +guint8 *mm_charset_utf8_to_unpacked_gsm (const gchar *utf8, + guint32 *out_len); +guint8 *mm_charset_gsm_unpacked_to_utf8 (const guint8 *gsm, + guint32 len); /* Checks whether conversion to the given charset may be done without errors */ -gboolean mm_charset_can_convert_to (const char *utf8, - MMModemCharset charset); +gboolean mm_charset_can_convert_to (const gchar *utf8, + MMModemCharset charset); guint8 *mm_charset_gsm_unpack (const guint8 *gsm, - guint32 num_septets, - guint8 start_offset, /* in bits */ - guint32 *out_unpacked_len); + guint32 num_septets, + guint8 start_offset, /* in bits */ + guint32 *out_unpacked_len); guint8 *mm_charset_gsm_pack (const guint8 *src, - guint32 src_len, - guint8 start_offset, /* in bits */ - guint32 *out_packed_len); - -gchar *mm_charset_take_and_convert_to_utf8 (gchar *str, MMModemCharset charset); + guint32 src_len, + guint8 start_offset, /* in bits */ + guint32 *out_packed_len); -gchar *mm_utf8_take_and_convert_to_charset (gchar *str, - MMModemCharset charset); +gchar *mm_charset_take_and_convert_to_utf8 (gchar *str, + MMModemCharset charset); +gchar *mm_utf8_take_and_convert_to_charset (gchar *str, + MMModemCharset charset); #endif /* MM_CHARSETS_H */ |