<tfoot id='k3A1K'></tfoot>
    <bdo id='k3A1K'></bdo><ul id='k3A1K'></ul>

<small id='k3A1K'></small><noframes id='k3A1K'>

    <i id='k3A1K'><tr id='k3A1K'><dt id='k3A1K'><q id='k3A1K'><span id='k3A1K'><b id='k3A1K'><form id='k3A1K'><ins id='k3A1K'></ins><ul id='k3A1K'></ul><sub id='k3A1K'></sub></form><legend id='k3A1K'></legend><bdo id='k3A1K'><pre id='k3A1K'><center id='k3A1K'></center></pre></bdo></b><th id='k3A1K'></th></span></q></dt></tr></i><div id='k3A1K'><tfoot id='k3A1K'></tfoot><dl id='k3A1K'><fieldset id='k3A1K'></fieldset></dl></div>
      <legend id='k3A1K'><style id='k3A1K'><dir id='k3A1K'><q id='k3A1K'></q></dir></style></legend>

        Visual Studio C++ 2015 std::codecvt with char16_t 或 char32_t

        Visual Studio C++ 2015 std::codecvt with char16_t or char32_t(Visual Studio C++ 2015 std::codecvt with char16_t 或 char32_t)

              • <tfoot id='llCUr'></tfoot>
                  <bdo id='llCUr'></bdo><ul id='llCUr'></ul>

                    <tbody id='llCUr'></tbody>
                • <small id='llCUr'></small><noframes id='llCUr'>

                • <legend id='llCUr'><style id='llCUr'><dir id='llCUr'><q id='llCUr'></q></dir></style></legend>
                  <i id='llCUr'><tr id='llCUr'><dt id='llCUr'><q id='llCUr'><span id='llCUr'><b id='llCUr'><form id='llCUr'><ins id='llCUr'></ins><ul id='llCUr'></ul><sub id='llCUr'></sub></form><legend id='llCUr'></legend><bdo id='llCUr'><pre id='llCUr'><center id='llCUr'></center></pre></bdo></b><th id='llCUr'></th></span></q></dt></tr></i><div id='llCUr'><tfoot id='llCUr'></tfoot><dl id='llCUr'><fieldset id='llCUr'></fieldset></dl></div>
                  本文介绍了Visual Studio C++ 2015 std::codecvt with char16_t 或 char32_t的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这段代码在VS2013下编译OK:

                  This code compiled OK under VS2013:

                  std::string Unicode::utf16_to_utf8(std::u16string utf16_string)
                  {
                      std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
                      return convert.to_bytes(utf16_string);
                  }
                  

                  现在使用 VS2015 我得到:

                  Now with VS2015 I get:

                  1>unicode.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class std::locale::id std::codecvt<char16_t,char,struct _Mbstatet>::id" (__imp_?id@?$codecvt@_SDU_Mbstatet@@@2V0localeA)
                  

                  推荐答案

                  老问题,但供以后参考:这是 Visual Studio 2015 中的一个已知错误,如 此主题 MSDN Social.

                  Old question, but for future reference: this is a known bug in Visual Studio 2015, as explained in the latest post (January 7th 2016) in this thread of MSDN Social.

                  您示例的解决方法如下所示(为简单起见,我将您的方法实现为免费函数):

                  The workaround for your example looks like this (I implemented your method as a free function for simplicity):

                  #include <codecvt>
                  #include <locale>
                  #include <string>
                  #include <iostream>
                  
                  #if _MSC_VER >= 1900
                  
                  std::string utf16_to_utf8(std::u16string utf16_string)
                  {
                      std::wstring_convert<std::codecvt_utf8_utf16<int16_t>, int16_t> convert;
                      auto p = reinterpret_cast<const int16_t *>(utf16_string.data());
                      return convert.to_bytes(p, p + utf16_string.size());
                  }
                  
                  #else
                  
                  std::string utf16_to_utf8(std::u16string utf16_string)
                  {
                      std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
                      return convert.to_bytes(utf16_string);
                  }
                  
                  #endif
                  
                  int main()
                  {
                      std::cout << utf16_to_utf8(u"lémentaire, mon cher Watson!") << std::endl;
                  
                      return 0;
                  }
                  

                  希望这个问题能在以后的版本中得到修复,否则#if条件需要细化.更新:不,在 VS 2017 中未修复.因此,我已将预处理器条件更新为 >=1900(最初为 ==1900).

                  Hopefully, the problem will be fixed in future releases, otherwise the #if condition will need refining. UPDATE: nope, not fixed in VS 2017. Therefore, I've updated the preprocessor conditional to >= 1900 (initially was == 1900).

                  这篇关于Visual Studio C++ 2015 std::codecvt with char16_t 或 char32_t的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                  Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                  Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                  Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                  How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                  Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)

                      <tbody id='NQ9Xk'></tbody>

                          • <bdo id='NQ9Xk'></bdo><ul id='NQ9Xk'></ul>
                            <i id='NQ9Xk'><tr id='NQ9Xk'><dt id='NQ9Xk'><q id='NQ9Xk'><span id='NQ9Xk'><b id='NQ9Xk'><form id='NQ9Xk'><ins id='NQ9Xk'></ins><ul id='NQ9Xk'></ul><sub id='NQ9Xk'></sub></form><legend id='NQ9Xk'></legend><bdo id='NQ9Xk'><pre id='NQ9Xk'><center id='NQ9Xk'></center></pre></bdo></b><th id='NQ9Xk'></th></span></q></dt></tr></i><div id='NQ9Xk'><tfoot id='NQ9Xk'></tfoot><dl id='NQ9Xk'><fieldset id='NQ9Xk'></fieldset></dl></div>

                            <legend id='NQ9Xk'><style id='NQ9Xk'><dir id='NQ9Xk'><q id='NQ9Xk'></q></dir></style></legend>

                            <small id='NQ9Xk'></small><noframes id='NQ9Xk'>

                            <tfoot id='NQ9Xk'></tfoot>