title: Converting chars into ASCII returns numbers too big
body: <p>So I have this function that XORes a string and then it turns it into a format like this:</p>
  
  <pre><code>\x55\x1\x53\x21...
  </code></pre>
  
  <p>But the problem is that the function firstly returned negative values, but I fixed that by making it from a CHAR into a UCHAR, but now it starts giving me values that are too big and the compiler doesn't let me compile because of it. Any thoughts of why this would happen? Couldn't find anything about it online.</p>
  
  <pre><code>__inline char* EncryptString(const char* String, const char* Key)
  {
      char* szEncrypted = new char[lstrlenA(String) + 1];
      memcpy(szEncrypted, String, lstrlenA(String) + 1);
  
      for (int32_t i = 0; i &lt; lstrlenA(String); ++i)
          szEncrypted[i] = String[i] ^ Key[i % (lstrlenA(Key))];
  
      std::stringstream lpStream;
  
      for (int32_t i = 0; i &lt; lstrlenA(szEncrypted); ++i)
      {
          char cCharInd       = szEncrypted[i];
          UINT nCharNum       = UINT(cCharInd);
  
          lpStream &lt;&lt; "\\x" &lt;&lt; std::hex &lt;&lt; nCharNum;
      }
  
      std::string sHexEscaped = lpStream.str();
      lpStream.clear();
  
      delete[] szEncrypted;
  
      char* szReturn = new char[sHexEscaped.length() + 1];
      memcpy(szReturn, sHexEscaped.c_str(), sHexEscaped.length() + 1);
  
      return szReturn;
  }
  </code></pre>