I'm looking for a bit of advice on the best way to convert a std::wstring
to std::string
- but a quick and dirty conversion for use as a key in an std::map<std::string, int>
object.
The map is quite large, and is already well integrated into the project already, and there are only a handful of keys that require this conversion so I think it will be wasteful to change the map into one that accepts std::wstring
as the key.
The output of the conversion doesn't really matter, but it has to be consistent so as to reliably pull the correct values from the map every time.
The application is a Windows only application.
Is there any known process to do a rough conversion reliably for this purpose? Or would the best way be via the usual, proper, conversion process (as described in this SO question/answer: How to convert wstring into string?)?
Edit: Please bear in mind - losing information is fine as long as things are consistent. i.e. If I throw in some Japanese characters, and they consistently convert into the same (potentially garbage) std::string
, that's fine. This will never be for display, only to be used as a key to pull out values from a map.
Thanks!