[PATCH] Support of UCS2 for SMS/USSD

Harald Welte laforge at gnumonks.org
Fri Feb 8 10:14:06 UTC 2013

Hi Pavel,

On Fri, Feb 08, 2013 at 01:55:52PM +0400, Pavel Baturko wrote:
> Another way to get this information that I know is smthng like that:
> +		old_locale = setlocale(LC_ALL, NULL);
> +		curr_locale = setlocale(LC_ALL, "");
> +		for (i = 0; i < strlen(curr_locale); i++)
> +			curr_locale[i] = tolower(curr_locale[i]);
> +		have_utf8_locale = ((strstr(curr_locale, "utf-8") != NULL) ||
> +							(strstr(curr_locale, "utf8" ) != NULL)) ? 1 : 0;
> +		setlocale(LC_ALL, old_locale);
> Not sure if it's ok because of temporary changing of current locale.
> unfortunately I was not able to find better ways to check locale.

the locale setting is only for the current program.  And as indicated,
at least so far, most libosmocore users are single-threaded, i.e. nobody
would notice if the locale was different for a very short amount of
time.  Furthermore, assuming that the code is not called all that often
(i.e. only once at program startup) I wouldn't be worried about that so

I am not an expert in locale.h matters, but it would somehow be strange
to me if you cannot determine utf-8 support without having to actually
change the locale.  Is anyone on this list more familiar with it?

> > 2) the function "ucs2_to_utf8_decode" is cluttering the global namespace
> >    even further.   Yes, it is in principle not a function related to
> >    gsm, but I'd still appreciate if it would start with osmo_ or gsm_
> >    prefix in order to make sure we don't clash with applications or
> >    other libraries using the same symbol name.
> I can move it to utils.c, is it acceptable? And of course add "osmo_" prefix.

yes, that would be appreciated, thanks.

- Harald Welte <laforge at gnumonks.org>           http://laforge.gnumonks.org/
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)

More information about the baseband-devel mailing list