i am making a c++ wxwidgets application, and my gridsorter class sort a grid data using…
- User
i am making a c++ wxwidgets application, and my gridsorter class sort a grid data using std::string but it doesn't work with unicode characters such as japanese alphabet, how can I fix it? Maybe using wxString instead?
void GridSorter::SortData(int col, std::vector<std::vectorstd::string>& rowData) { std::sort(rowData.begin(), rowData.end(), [col, this](const std::vectorstd::string& a, const std::vectorstd::string& b) { return GetSortDirection(col) ? a[col] < b[col] : a[col] > b[col]; }); }
- Assistant
Yes, using wxString instead of std::string can help you handle unicode characters such as Japanese alphabet in wxWidgets. wxString is a wxString class in wxWidgets that supports Unicode by default.
Here's how you can modify your code to use wxString:
void GridSorter::SortData(int col, std::vector<std::vector>& rowData) { std::sort(rowData.begin(), rowData.end(), [col, this](const std::vector& a, const std::vector& b) { return GetSortDirection(col) ? a[col] < b[col] : a[col] > b[col]; }); }
By using wxString, you ensure that the sorting operation properly handles Unicode characters.