How to read from file UTF simbols as if they were UTF code?

So I have a file - html file there are lots of simbols like &'""""</\>9()!@#+=- I need to convert them into a form that can be copied from output screen so to be after passed to std::string str ("Here should be UTF simbols"); how to do such thing (using C++ boost)


This code assumes the compiling system uses a superset of ASCII, which is reasonable on today's systems. It gives a string literal as a std::string, including surrounding quotes. The input data is treated as generic bytes rather than required to be UTF-8.

std::string string_literal(int length, char const *data) {
  std::stringstream s;
  std::ostream shex (s.rdbuf());
  shex << std::hex << std::uppercase;

  s << '"';
  for (int n = 0; n != length; ++n) {
    unsigned char c = data[n];
    if (c < 32 || 0x7F <= c) {
      // add special cases for \n, \t, \r, etc. to produce nicer output
      shex << "\\x" << std::setw(2) << int(c);
    else {
      switch (c) {
      case '"':
      case '\\':
        s << '\\' << c;

        s << c;
  s << '"';
  return s.str();


// for string literals, makes below example easier
template<int N>
std::string string_literal(char const (&data)[N]) {
  assert(data[N - 1] == '\0');
  return string_literal(N - 1, data);

// another convenience overload
std::string string_literal(std::string const &s) {
  return string_literal(s.length(),;

int main() {
  std::cout << "#include <iostream>\nint main() {\n  std::cout << ";
  std::cout << string_literal("&'\"</\\>9()!@#+=-") << "\n            << ";
  std::cout << string_literal("☺ ☃ ٩(•̮̮̃•̃)۶") << ";\n}\n";
    // first and second are a smiley face and snowman
    // the third may not display correctly on your browser
  return 0;


#include <iostream>
int main() {
  std::cout << "&'\"</\\>9()!@#+=-"
            << "\xE2\x98\xBA \xE2\x98\x83 \xD9\xA9(\xE2\x80\xA2\xCC\xAE\xCC\xAE\xCC\x83\xE2\x80\xA2\xCC\x83)\xDB\xB6";

Need Your Help

Randomly generate a line from a .txt file

python random printing words

I'm rather new to python and have been set an assignment. I need to randomly generate a word from a .txt file. I can retrieve specific lines, such a get line 2, or line 5, however I want to randomly

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.