Skip to content

Instantly share code, notes, and snippets.

@Arkanosis
Created March 14, 2018 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arkanosis/6a1b449452ad396e6a2729a081616227 to your computer and use it in GitHub Desktop.
Save Arkanosis/6a1b449452ad396e6a2729a081616227 to your computer and use it in GitHub Desktop.
Break std::strftime using a Japanese CP932 locale on Windows
#include <ctime>
#include <iostream>
#include <locale>
int main() {
std::locale::global(std::locale("Japanese_Japan.932"));
std::time_t t = std::time(nullptr);
char mbstr[20000];
if (std::strftime(mbstr, sizeof (mbstr), "%Y年%m月%d日 %H:%M:%S", std::localtime(&t))) {
std::cout << mbstr << '\n';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment