utils.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef RUNNER_UTILS_H_
  2. #define RUNNER_UTILS_H_
  3. #include <string>
  4. #include <vector>
  5. // Creates a console for the process, and redirects stdout and stderr to
  6. // it for both the runner and the Flutter library.
  7. void CreateAndAttachConsole();
  8. // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
  9. // encoded in UTF-8. Returns an empty std::string on failure.
  10. std::string Utf8FromUtf16(const wchar_t* utf16_string);
  11. // Takes a null-terminated char* encoded in UTF-8 and returns a std::wstring
  12. // encoded in UTF-16. Returns an empty std::wstring on failure.
  13. std::wstring Utf16FromUtf8(const char* utf8_string);
  14. // Convert a wide Unicode string to an UTF8 string
  15. std::string utf8_encode(const std::wstring &wstr);
  16. // Convert an UTF8 string to a wide Unicode String
  17. std::wstring utf8_decode(const std::string &str);
  18. // Gets the command line arguments passed in as a std::vector<std::string>,
  19. // encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
  20. std::vector<std::string> GetCommandLineArguments();
  21. // trims whitespace from the left side of a string
  22. const std::string ltrim(const std::string &s);
  23. // trims whitespace from the right side of a string
  24. const std::string rtrim(const std::string &s);
  25. // trims whitespace from both sides of a string
  26. const std::string trim(const std::string &s);
  27. #endif // RUNNER_UTILS_H_