I need to load an HTML template file (using std::ifstream
), add some content and then save it as a complete web page. It would be simple enough if not for polish characters - I've tried all combinations of char
/wchar_t
, Unicode
/Multi-Byte
character set, iso-8859-2
/utf-8
, ANSI
/utf-8
and none of them worked for me (always got some incorrectly displayed characters (or some of them not displayed at all).
I could paste a lot of code and files here but I'm not sure if that would even help. But maybe you could just tell me: what format/encoding should the template file have, what encoding should I declare in it for the web page and how should I load and save that file to get proper results?
(If my question is not specific enough or you do require code/file examples, let me know.)
Edit: I've tried the library suggested in the comment:
std::string fix_utf8_string(std::string const & str)
{
std::string temp;
utf8::replace_invalid(str.begin(), str.end(), back_inserter(temp));
return str;
}
Call:
fix_utf8_string("wynik działania pozytywny ąśżźćńłóę");
Throws: utf8::not_enough_room
- what am I doing wrong?