hstring_test.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "hstring.h"
  2. int main(int argc, char** argv) {
  3. /*
  4. char str1[] = "a1B2*C3d4==";
  5. char str2[] = "a1B2*C3d4==";
  6. printf("strupper %s\n", strupper(str1));
  7. printf("strlower %s\n", strlower(str2));
  8. char str3[] = "abcdefg";
  9. printf("strreverse %s\n", strreverse(str3));
  10. char str4[] = "123456789";
  11. printf("strstartswith=%d\nstrendswith=%d\nstrcontains=%d\n",
  12. (int)strstartswith(str4, "123"),
  13. (int)strendswith(str4, "789"),
  14. (int)strcontains(str4, "456"));
  15. */
  16. std::string str5 = asprintf("%s%d", "hello", 5);
  17. printf("asprintf %s\n", str5.c_str());
  18. std::string str6("123,456,789");
  19. StringList strlist = split(str6, ',');
  20. printf("split %s\n", str6.c_str());
  21. for (auto& str : strlist) {
  22. printf("%s\n", str.c_str());
  23. }
  24. std::string str7("user=admin&pswd=123456");
  25. hv::KeyValue kv = splitKV(str7, '&', '=');
  26. for (auto& pair : kv) {
  27. printf("%s=%s\n", pair.first.c_str(), pair.second.c_str());
  28. }
  29. std::string str8("<stdio.h>");
  30. std::string str9 = trim_pairs(str8);
  31. printf("trim_pairs %s\n", str9.c_str());
  32. std::string str10("<title>{{title}}</title>");
  33. std::string str11 = replace(str10, "{{title}}", "Home");
  34. printf("replace %s\n", str11.c_str());
  35. return 0;
  36. }