0

I tried to output contents to a file

  std::locale::global(std::locale());
  std::wofstream file(outfilename , std::wofstream::binary);

  for (const auto & j : grid[0]) {
      try {
          std::wcout << L"String in WideString " << decoder->decode(j) << std::endl;
          file << decoder->decode(j) << std::endl;
      }
      catch (std::exception& e) {
          std::cout << e.what() << std::endl;
      }

  }

wcout stops outputting anything ( even "String in WideString" is not outputted ) after some amount of calls,

(I debugged it and it executes wcout like supposed to, after it stopped outputting text)

wofstream also stops outputting after the same amount of calls.

This is the first time I used the widestrings, streams and couts.

Thanks for looking into this.

nabz_32x
  • 3
  • 2
  • 2
    The main suspects are either `decoder`, `grid`, or `grid[0]`, or one of the `j`s being invalid; or `decode` doing something undefined. – molbdnilo May 18 '18 at 09:19
  • when i normal cout those characters, this cout will output, with the same j and grid – nabz_32x May 18 '18 at 09:20
  • also when I leave out my own decoder the same happens – nabz_32x May 18 '18 at 09:20
  • it only stops working when I resort to wcout and wofstream for the file stream – nabz_32x May 18 '18 at 09:21
  • this is working fine for me and as stated by @molbdnilo issue seems to be with decode or grid https://repl.it/repls/PolishedEmptyActivemovie – PapaDiHatti May 18 '18 at 09:23
  • As is the nature of undefined behaviour, the root cause may of course also be located somewhere else entirely. – molbdnilo May 18 '18 at 09:26
  • Hmm, I am using the string directly if i don use my own encode function... Than it must have to do something with grid, but the characters are all put out with cout on the same grid, strange. Is there a certain character that can break wcout? – nabz_32x May 18 '18 at 09:29
  • this is the character, after which nothing works anymore "€" – nabz_32x May 18 '18 at 09:50

1 Answers1

0

it is the € sign, that stops wcout and wofstream from working, removing that from the input file, I get the data from, makes everything work like expected, very strange

nabz_32x
  • 3
  • 2
  • Even stranger, when testing outputting the € sign before, no problems arose, only after using it in exactly this context, this error occured. – nabz_32x May 18 '18 at 10:23