wirbel-at-vdr-portal / vdr-plugin-satip

SAT>IP plugin for the Video Disk Recorder (VDR)
https://github.com/rofafor/vdr-plugin-satip
GNU General Public License v2.0
2 stars 2 forks source link

replace ',' with '.' in float type frequency on german systems #6

Closed kfb77 closed 8 months ago

kfb77 commented 8 months ago

I found the issue described here. The OctopusNet does not accept a ',' in the freqency field from the setup request. Here the output from a trace from the setup request: Request: SETUP rtsp://10.1.15.217/?src=1&freq=10714,000&pol=h&ro=0.35&msys=dvbs2&mtype=8psk&sr=22000&fec=23 RTSP/1.0\r\n The issue only occurs on system with ',' as separator in float values.

wirbel-at-vdr-portal commented 8 months ago

Hi kfb77,

i would include this one as

 auto PrintFloat = [](float& f) -> std::string {
    char buf[32];
    snprintf(buf, sizeof(buf), "%.3f", f);
    std::string s((const char *) buf);
    ReplaceAll(s, ",", ".");
    return s;
    };

Also, i would add a line into HISTORY.

Some small test program to confirm, use g++ -Wall -Wextra test.cpp -o testme -lrepfunc

#include <iostream>
#include <clocale>
#include <repfunc.h>

int main() {
     auto PrintFloat = [](float& f) -> std::string {
        char buf[32];
        snprintf(buf, sizeof(buf), "%.3f", f);
        std::string s((const char *) buf);
        ReplaceAll(s, ",", ".");
        return s;
        };
  std::setlocale(LC_NUMERIC, "de_DE.UTF-8");
  float f = 400.33;
  std::cout << PrintFloat(f) << std::endl;
  return 0;
}
kfb77 commented 8 months ago

I have testet it with the current code from branch "wirbel" and no problems so far. Thx. I close the PR.