0

I'm working in a software that need to save a utf-8 file with special characters (like 'çäüëé').

I received the content to save (regular string with special characters encoded) from a webservice (with gsoap). When I try to save, using ofstream, the file saves a square and other strange characters instead of special characters.

When I try to convert the regular string to a wide string, it's lost the special characters (it is replaced by different ones). And, using wofstream, the file not saves the file when there are special characters.

I try to use also utf8-cpp, but the file it wasn't wrote correct too.

ST3
  • 8,826
  • 3
  • 68
  • 92
Felipe Reis
  • 41
  • 1
  • 7
  • Possible duplicate of: http://stackoverflow.com/questions/3011082/c-stdstring-and-utf-8 – MobA11y May 29 '13 at 17:59
  • Also, be sure whatever text editor you have isn't the culprit. Your file can contain correct utf-8 and your text editor could be corrupting the output. In particular if you are using 'cat' from the terminal, or one of the basic terminal/gnu editors. – MobA11y May 29 '13 at 18:01
  • 3
    Your question doesn't provide much detail on what you're doing or what is actually going wrong. Start by looking at the data you get from gsoap; look at the integral byte values and see if those numbers match up to the encoding you expect. Also look at the integral byte values being written in the file, perhaps using a hex editor, to see if the right values are being written. If that file has the right values then the problem is probably just that your text editor is using the wrong encoding to display the file. – bames53 May 29 '13 at 18:01
  • The bytes come from gsoap seens correct, but file wasn't write correct. I try to put the byte order marker also, and continues wrong. I use gedit, kate and google chrome to open the file (it is a xml file) and all them shows that file is wrong. – Felipe Reis May 29 '13 at 18:48

0 Answers0