LaurentGomila/SFML — pull request #408 by Oberon00 (2013-06-15 17:48:13+00:00)
Title: Improve Wide char <-> sf::String/sf::Utf <-> ANSI conversions.

This should fix #407.

I have to say, that I don't have *too* much time for coding right now, so I only did superficial testing with the following code:

```c++
#include
#include
#include
#include
#include

int main()
{
//char const cp1252[] = "gr\xfc\xdf""e";
char const utf8[] = "gr\xc3\xbc\xc3\x9f""e";
std::size_t const u8len = sizeof(utf8) / sizeof(utf8[0]) - 1;
sf::Uint32 const utf32[] = {103, 114, 252, 223, 101};
std::size_t const u32len = sizeof(utf32) / sizeof(utf32[0]);
std::locale::global(boost::locale::generator().generate(""));
//std::locale::global(std::locale("German_Germany.1252");
sf::String s(utf8);
std::string ansi = s;

assert(s.getSize() == u32len);
for (std::size_t i = 0; i < u32len; ++i) {
assert(s[i] == utf32[i]);
}

assert(ansi.size() == u8len);
for (std::size_t i = 0; i < u8len; ++i) {
assert(ansi[i] == utf8[i]);
}
}

```
The assertions hold with this version but fail with the old implementation.
I also tested at least sf::String -> ANSI conversion with "built in" locales and code page 1252 (a rest of it is in the commented out lines). This works with both implementations.

I know that I have worsened code duplication but I cannot (or at least should not ;-) ) invest more time right now.

I think I have, however, enough time to adjust the code to your preferred style, if you tell me what doesn't fit.