title: Bit-Shift a string to decode save file C++
body: <p>I am kinda trying to decode my save files. And I came up with this. But shifting the characters back from the save file doesn't seem to work properly. Only the numbers seem to recover correctly but all the other characters seem to change into strange symbols. As you can see I bit-shift the savecontent &lt;&lt; 1 to the left, and on load I bit-shift the incoming line >> 1 to the right. But it doesn't work as I expected. Does bit-shift not work properly on strings?</p>
  
  <pre><code>void erGuiManager::SaveToFile(string filename) {
      ofstream ifs;
      ifs.open(filename, ios::binary);
  
      if (ifs.is_open())
      {
          string savecontent = "";
          for (int i = 0; i &lt; guiItems.size(); i++) {
              if (dynamic_cast&lt;erGuiBasicNode*&gt;(guiItems[i])) {
                  savecontent.append( dynamic_cast&lt;erGuiBasicNode*&gt;(guiItems[i])-&gt;save(true));
              }
          }
          for (int i = 0; i &lt; savecontent.length(); i++) {
              savecontent[i] = savecontent[i] &lt;&lt; 1;
          }
          ifs.write(savecontent.c_str(), strlen(savecontent.c_str()));
          ifs.close();
      }
      else {
          cout &lt;&lt; "Error: Unable to open file " &lt;&lt; filename;
      }
  }
  
  void erGuiManager::LoadFromFile(string filename) {
      string line;
      string out;
      ifstream myfile(filename);
      if (myfile.is_open())
      {
          while (getline(myfile, line))
          {
              for (int i = 0; i &lt; line.length(); i++) {
                  line[i] = line[i] &gt;&gt; 1;
              }
              out.append(PasteNodeFromString(line,true));
          }
          ConnectBezierLines(out);
          myfile.close();
      }
  }
  </code></pre>