Skip to content

Instantly share code, notes, and snippets.

@pebble8888
Last active November 26, 2023 01:22
Show Gist options
  • Save pebble8888/95220cd72e4c52988310d6966e532d6f to your computer and use it in GitHub Desktop.
Save pebble8888/95220cd72e4c52988310d6966e532d6f to your computer and use it in GitHub Desktop.
std::filesystem::path
#include <iostream>
#include <filesystem>
#include <stdio.h>
#include <wchar.h>
int main(int argc, const char * argv[]) {
std::filesystem::path path1 = "あ";
const auto str_a = path1.string();
const unsigned char* a = (const unsigned char*)str_a.c_str();
printf("a: %04x %04x %04x %04x\n", *a, *(a+1), *(a+2), *(a+3));
const auto wstr_b = path1.wstring();
const wchar_t* b = wstr_b.c_str();
printf("b: %04x %04x %04x %04x\n", *b, *(b+1), *(b+2), *(b+3));
std::filesystem::path path2 = L"あ";
const auto str_c = path2.string();
const unsigned char* c = (const unsigned char*)str_c.c_str();
printf("c: %04x %04x %04x %04x\n", *c, *(c+1), *(c+2), *(c+3));
const auto wstr_d = path2.wstring();
const wchar_t* d = wstr_d.c_str();
printf("d: %04x %04x %04x %04x\n", *d, *(d+1), *(d+2), *(d+3));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment