CCExtractor / ccextractor

CCExtractor - Official version maintained by the core team

Home Page:https://www.ccextractor.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output format depends on the POSIX locale LC_NUMERIC

v-chvila opened this issue · comments

For example:

sprintf(str, " <p begin=\"%02u:%02u:%02u.%03u\" end=\"%02u:%02u:%02u.%03u\" tts:origin=\"%1.3f%% %1.3f%%\">\n <span>", h1, m1, s1, ms1, h2, m2, s2, ms2, col1, row1);

sprintf() is configured by LC_NUMERIC. See: https://linux.die.net/man/3/sprintf Format of the format string
Final output is inconsistent and it is hard to parse. Do you consider some better solution?

We can specify a locale before using sprintf to get the formatting we want, and then immediately return locale to C afterwards I believe?

The more I research, the more I think locales are a nightmare. I might try a fix for this, but wow

The more I research, the more I think locales are a nightmare. I might try a fix for this, but wow

The simplest solution is two just don't use float and use two ints instead. Here's what ChatGPT suggest (I haven't tried, but it gives you an idea)

sprintf(str, "      <p begin=\"%02u:%02u:%02u.%03u\" end=\"%02u:%02u:%02u.%03u\" tts:origin=\"%d.%03d%% %d.%03d%%\">\n        <span>",
        h1, m1, s1, ms1, h2, m2, s2, ms2, (int)(col1), (int)((col1 - (int)col1) * 1000), (int)(row1), (int)((row1 - (int)row1) * 1000));

Forget about locales :-)

Oh I see! I thought that they had to stay as floats :P

Oh I see! I thought that they had to stay as floats :P

No - just make sure the output is correct, i.e. always 3 digits (test for numbers ending in 0, 00, 000)...

@v-chvila Could you see if it's fixed for you in master?

Closing. @v-chvila feel free to reopen if you still have problems.