mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33:25 +00:00
[db2] Better trim.
This commit is contained in:
parent
bd121aff74
commit
ac847aedd8
1 changed files with 8 additions and 3 deletions
|
|
@ -330,11 +330,13 @@ struct db2 {
|
||||||
// converts string to utf8
|
// converts string to utf8
|
||||||
// filters out values with empty name ""
|
// filters out values with empty name ""
|
||||||
auto to_map(int cp) const {
|
auto to_map(int cp) const {
|
||||||
auto prepare_string = [&](auto &&in) {
|
auto prepare_string = [&](auto &&in, bool trim = false) {
|
||||||
auto s = str2utf8(in, cp);
|
auto s = str2utf8(in, cp);
|
||||||
// we have some erroneous table values (records) with spaces
|
// we have some erroneous table values (records) with spaces
|
||||||
// we can trim only field values, but don't do it at the moment
|
// we can trim only field values, but don't do it at the moment
|
||||||
//boost::trim(s);
|
if (trim) {
|
||||||
|
boost::trim(s);
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -377,7 +379,10 @@ struct db2 {
|
||||||
jv[fn] = *(float *)p;
|
jv[fn] = *(float *)p;
|
||||||
break;
|
break;
|
||||||
case db2::field_type::string:
|
case db2::field_type::string:
|
||||||
jv[fn] = boost::trim_copy(prepare_string((const char *)p)); // trim field value
|
// also trim 'NAME' field value
|
||||||
|
jv[fn] = prepare_string((const char *)p, fn == "NAME"s);
|
||||||
|
// we cannot trim, some strings should end (and start?) with space
|
||||||
|
//jv[fn] = boost::trim_copy(prepare_string((const char *)p)); // trim field value
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw std::logic_error{"bad type"};
|
throw std::logic_error{"bad type"};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue