22#ifndef JKQTPSTRINGTOOLS_H_INCLUDED
23#define JKQTPSTRINGTOOLS_H_INCLUDED
24#include "jkqtcommon/jkqtcommon_imexport.h"
75inline QString jkqtp_UnicodeToUTF8Q(uint32_t codepoint) {
83 QLocale loc=QLocale::c();
84 loc.setNumberOptions(QLocale::OmitGroupSeparator);
85 return loc.toString(value,
'g', 18);
91inline QString
JKQTPDoubleToQString(
double value,
int prec = 10,
char f =
'g', QChar decimalSeparator=
'.') {
92 QLocale loc=QLocale::c();
93 loc.setNumberOptions(QLocale::OmitGroupSeparator);
94 QString res=loc.toString(value, f, prec);
95 if (loc.decimalPoint()!=decimalSeparator) {
96 res=res.replace(loc.decimalPoint(), decimalSeparator);
105inline QString&
JKQTPExtendString(QString& s,
const QString& separator,
const QString& extension) {
106 if (s.size()>0) s+=separator;
131 snprintf(buffer, 4096, templ.c_str(), d1);
132 return std::string(buffer);
138template <
class T1,
class T2>
139inline std::string
jkqtp_format(
const std::string& templ, T1 d1, T2 d2) {
141 snprintf(buffer, 4096, templ.c_str(), d1, d2);
142 return std::string(buffer);
148template <
class T1,
class T2,
class T3>
149inline std::string
jkqtp_format(
const std::string& templ, T1 d1, T2 d2, T3 d3) {
151 snprintf(buffer, 4096, templ.c_str(), d1, d2, d3);
152 return std::string(buffer);
158template <
class T1,
class T2,
class T3,
class T4>
159inline std::string
jkqtp_format(
const std::string& templ, T1 d1, T2 d2, T3 d3, T4 d4) {
161 snprintf(buffer, 4096, templ.c_str(), d1, d2, d3, d4);
162 return std::string(buffer);
273JKQTCOMMON_LIB_EXPORT std::string
jkqtp_floattolatexstr(
double data,
int past_comma=5,
bool remove_trail0=
false,
double belowIsZero=1e-16,
double minNoExponent=1e-3,
double maxNoExponent=1e4,
bool ensurePlusMinus=
false,
const std::string& multOperator=
"\\times");