Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

Problem with locale and sscanf (ofxImGui related)

$
0
0

@lilive wrote:

Hi,

I’m parsing a file containing this text:

Pos=60,10

The parsing code is:

float x, y;
sscanf( line, "Pos=%f,%f", &x, &y)

It takes the comma as a numeric dot and it give

x = 60.10
y = 0.0

instead of

x = 60.0
y = 10.0

I’ve found that I can put:

#include <locale.h>
setlocale(LC_NUMERIC, "C")

in my ofApp.cpp to fix it.

But I don’t know if this is a good idea, or if I must expect some problems later in other parts af my app.
I’m not familiar with the locale subject. I can tell that this is the output of the command locale in the MSYS2 MINGW 32 console:

$ locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_ALL=

I’m using OF0.10.0 msys release, QtCreator and Windows 7.

Can you give me some advices ?
I would prefer not to change the parsing code, because it is part of ImGui, in the SettingsHandlerWindow_ReadLine function.
I’m making an app with ofxImGui (by @jvcleave) , and the problem is that ofxImGui fail to read the settings saved by the previous run of the app because of this problem.

Thanks :slight_smile:

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles