<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                wstring 是指的寬字節。 ~~~ typedef basic_string<char> string; typedef basic_string<wchar_t> wstring; ~~~ 在實際工程中,我們往往需要把string轉換為wstring,你可以會進行百度或是Google,很輕松找到轉換的方法。但是這里就隱含著巨大的坑兒。 看看這個轉換吧: ~~~ std::wstring WStringToWString(const std::string& str) { int size_str = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0); wchar_t *wide = new wchar_t[size_str]; MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, wide, size_str); std::wstring return_wstring(wide); delete[] wide; wide = NULL; return return_wstring; } ~~~ 也許上面的代碼幫你解決了問題,但是暫時的。當str = “我是中文”的時候,你會發現,無法完成正確的轉換,導致亂碼。 因此,為了增加你程序的健壯性,還是尋找另一種方法吧,如下: ~~~ std::wstring StringToWString(const std::string& str) { setlocale(LC_ALL, "chs"); const char* point_to_source = str.c_str(); size_t new_size = str.size() + 1; wchar_t *point_to_destination = new wchar_t[new_size]; wmemset(point_to_destination, 0, new_size); mbstowcs(point_to_destination, point_to_source, new_size); std::wstring result = point_to_destination; delete[]point_to_destination; setlocale(LC_ALL, "C"); return result; } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看