// 輸出中文
char szA[8];
WCHAR szW[8];
sprintf(szA, "%s", L"和平"); // 亂碼,四個字節
sprintf(szA, "%s", "和平"); // 和平
sprintf(szA, "%S", L"和平"); // 零字節
sprintf(szA, "%S", "和平"); // 零字節
swprintf(szW, L"%s", L"和平"); // 和平,四個字節
swprintf(szW, L"%s", "和平"); // 無法輸出,四個字節,內容是ANSI碼
swprintf(szW, L"%S", L"和平"); // 無法輸出,八個字節,內容是Unicode碼
swprintf(szW, L"%S", "和平"); // 無法輸出,八個字節,內容是ANSI碼
wsprintfA(szA, "%s", L"和平"); // 亂碼,四個字節
wsprintfA(szA, "%s", "和平"); // 和平
wsprintfA(szA, "%S", L"和平"); // 和平
wsprintfA(szA, "%S", "和平"); // 亂碼,兩個字節
wsprintfW(szW, L"%s", L"和平"); // 和平,四個字節
wsprintfW(szW, L"%s", "和平"); // 無法輸出,四個字節,內容是ANSI碼
wsprintfW(szW, L"%S", L"和平"); // 無法輸出,六個字節,內容是Unicode碼
wsprintfW(szW, L"%S", "和平"); // 和平,八個字節
// 輸出英文
char szA[8];
WCHAR szW[8];
sprintf(szA, "%s", L"well"); // w,一個字節
sprintf(szA, "%s", "well"); // well,四個字節
sprintf(szA, "%S", L"well"); // well,四個字節
sprintf(szA, "%S", "well"); // 零字節
swprintf(szW, L"%s", L"well"); // well,八個字節
swprintf(szW, L"%s", "well"); // 亂碼,四個字節
swprintf(szW, L"%S", L"well"); // w,兩個字節
swprintf(szW, L"%S", "well"); // well,八個字節
wsprintfA(szA, "%s", L"well"); // w,一個字節
wsprintfA(szA, "%s", "well"); // well,四個字節
wsprintfA(szA, "%S", L"well"); // well,四個字節
wsprintfA(szA, "%S", "well"); // 亂碼,四個字節
wsprintfW(szW, L"%s", L"well"); // well,八個字節
wsprintfW(szW, L"%s", "well"); // 亂碼,四個字節,內容是ANSI碼
wsprintfW(szW, L"%S", L"well"); // w,兩個字節
wsprintfW(szW, L"%S", "well");
|