Strange behavior while creating SMS with non-ASCII chars with mmcli

Aleksander Morgado aleksander at aleksander.es
Sat Mar 19 18:29:34 UTC 2016


Hey,

>
> I have dedicated some time to this issue again. The problem is that creating
> an SMS with UTF-8 chars fails, no SMS is created.
>
> I checked charset encoding all over the place: PHP, shell, etc. It all
> *seems* coherent.
>

What do yo mean with seems coherent? What's the locale in each case?

> If I create the SMS with mmcli in the command line it works.
>

Good; this means mmcli is picking up your system locale, which likely
is UTF-8 based.

> If I create the SMS with mmcli from a bash script if fails. Other commands
> in the script, like -e and --simple-connect, work.
>

I'm assuming you want non-ASCII characters in the SMS, right? Other
commands likely just require only ASCII.

> I've built the latest version 1.5.990 and added this code to the beginning
> of the main function:
>
> gint
> main (gint argc, gchar **argv)
> {
>     GDBusConnection *connection;
>     GOptionContext *context;
>     GError *error = NULL;
>
>     gint i;
>     for (i = 0; i < argc; ++i) {
>         g_print("argv[%d] = %s\n", i, argv[i]);
>     }
>
> This is the result when the error occurs:
>
>  argv[0] = /home/fidelio/mm/ModemManager-1.5.990/cli/.libs/lt-mmcli
>  argv[1] = -m
>  argv[2] = 4
>  [Invalid UTF-8] argv[3] = --messaging-create-sms=text='Este \xe9 um texto
> com acentos em portugu\xeas, Jo\xe3o Silva',number=123456789
>
> It looks like a strange [Invalid UTF-8] message is printed. Any hints?
>

I believe this is totally unrelated to your issue. Your code is
executed before setlocale() is run, so the program didn't check what
the environment locale was and it just assumed the default C locale.
E.g. try with this:

#include <glib.h>
#include <locale.h>

gint
main (gint argc, gchar **argv)
{
    gint i;

    setlocale (LC_ALL, "");

    for (i = 0; i < argc; ++i) {
        g_print("argv[%d] = %s\n", i, argv[i]);
    }

    return 0;
}

$ gcc -o test `pkg-config --cflags --libs glib-2.0` test.c
$ ./test --something="ññññ"
argv[0] = ./test
argv[1] = --something=ññññ

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list