Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Last active February 22, 2017 23:37
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 chuck0523/d4ca5fabb1497b7aac2d2be3b760559e to your computer and use it in GitHub Desktop.
Save chuck0523/d4ca5fabb1497b7aac2d2be3b760559e to your computer and use it in GitHub Desktop.
string S = "パタトクカシーー"
cout << S[0] // "パ"ではなく文字化けが表示される
// 3バイト分取得すればOKだった
size_t one_char = 3;
cout << S.substr(0, one_char); // "パ"
// パトカー抽出
for(int i = 0; i < one_char * 4; i++) {
cout << S.substr(i * one_char * 2, one_char); // パトカー
}
cout << endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment