Here is incorrect text formating with using cout() with setw() in UNICODE (UTF-8) Two text: first in English - correct formating, second - russian in UTF-8 - incorrect.
#include <iostream> #include <iomanip> int main() { std::cout.setf(std::ios::left); std::cout.fill('_'); std::cout << std::setw(15) << "Mixer" << std::setw(15) << "Device" << std::setw(15) << "Recording" << std::setw(15) << "Active" << std::setw(15) << "Stereo" << std::setw(15) << "Current" << std::endl; std::cout << std::setw(15) << "Channel" << std::setw(15) << "Available" << std::setw(15) << "Source" << std::setw(15) << "Source" << std::setw(15) << "Device" << std::setw(15) << "Level" << std::endl; std::cout << std::endl; // Russian text in UTF-8 // Not correct formating text.... std::cout << std::setw(15) << "Êàíàë" << std::setw(15) << "Äîñòóïíîñòü" << std::setw(15) << "Èñòî÷íèê" << std::setw(15) << "Àêòèâíîñòü" << std::setw(15) << "Ñòåðåî" << std::setw(15) << "Òåêóùèé" << std::endl; std::cout << std::setw(15) << "ìèêøåðà" << std::setw(15) << "óñòðîéñòâà" << std::setw(15) << "çàïèñè" << std::setw(15) << "èñòî÷íèêà" << std::setw(15) << "óñòðîéñòâî" << std::setw(15) << "óðîâåíü" << std::endl; return 0; } $ g++-4.2.2 bug.cpp -o bug RESULT: Mixer__________Device_________Recording______Active_________Stereo_________Current________ Channel________Available______Source_________Source_________Device_________Level__________ Êàíàë_____ÄîñòóïíîñòüÈñòî÷íèêÀêòèâíîñòüÑòåðåî___Òåêóùèé_ ìèêøåðà_óñòðîéñòâàçàïèñè___èñòî÷íèêàóñòðîéñòâîóðîâåíü_ -- Summary: incorrect text formating in "std::cout" with UTF-8 Product: gcc Version: 4.2.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: siegerstein at pochta dot ru GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33852