Bug #1021 ยป honorMultiByteChar.diff
src/actions.cpp (Arbeitskopie) | ||
---|---|---|
149 | 149 |
exists and shouldn't be overwritten, else 0. |
150 | 150 |
*/ |
151 | 151 |
int dontOverwrite(const std::string& path); |
152 | ||
153 |
/*! |
|
154 |
@brief Output a text with a given minimum number of chars, honoring |
|
155 |
multi-byte characters correctly. Replace code in the form |
|
156 |
os << setw(width) << myString |
|
157 |
with |
|
158 |
os << make_pair( myString, width) |
|
159 |
*/ |
|
160 |
std::ostream& operator<<( std::ostream& os, std::pair< const std::string&, unsigned int> strAndWidth); |
|
152 | 161 |
} |
153 | 162 | |
154 | 163 |
// ***************************************************************************** |
... | ... | |
443 | 452 |
if (Params::instance().files_.size() > 1) { |
444 | 453 |
std::cout << std::setw(20) << path_ << " "; |
445 | 454 |
} |
446 |
std::cout << std::setw(align_)
|
|
447 |
<< label << ": ";
|
|
455 |
std::cout << std::make_pair( label, align_)
|
|
456 |
<< ": "; |
|
448 | 457 |
} |
449 | 458 | |
450 | 459 |
int Print::printTag(const Exiv2::ExifData& exifData, |
... | ... | |
2009 | 2018 |
return 0; |
2010 | 2019 |
} |
2011 | 2020 | |
2021 |
std::ostream& operator<<( std::ostream& os, std::pair< const std::string&, unsigned int> strAndWidth) |
|
2022 |
{ |
|
2023 |
const std::string& str( strAndWidth.first); |
|
2024 |
unsigned int minChCount( strAndWidth.second); |
|
2025 |
unsigned int count = mbstowcs( NULL, str.c_str(), 0); // returns 0xFFFFFFFF on error |
|
2026 |
if( count < minChCount) |
|
2027 |
{ |
|
2028 |
minChCount += str.size() - count; |
|
2029 |
} |
|
2030 |
return os << std::setw( minChCount) << str; |
|
2031 |
} |
|
2032 | ||
2012 | 2033 |
} |