標籤:
VisualStudio 2010 SP1環境
1、設定string預設編碼為utf8,只需要在檔案頭部加入以下代碼
1 #pragma execution_character_set("utf-8") //預設使用UTF8
2、debug提示視窗顯示utf8,開啟C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\autoexp.dat檔案找到第412到413行,原文如下:
1 std::basic_string<char,*>{2 preview ( #if (($e._Myres) < ($e._BUF_SIZE)) ( [$e._Bx._Buf,s] ) #else ( [$e._Bx._Ptr,s] ))3 stringview ( #if (($e._Myres) < ($e._BUF_SIZE)) ( [$e._Bx._Buf,sb] ) #else ( [$e._Bx._Ptr,sb] ))
修改為以下內容
1 std::basic_string<char,*>{2 preview ( #if (($e._Myres) < ($e._BUF_SIZE)) ( [$e._Bx._Buf,s8] ) #else ( [$e._Bx._Ptr,s8] ))3 stringview ( #if (($e._Myres) < ($e._BUF_SIZE)) ( [$e._Bx._Buf,s8b] ) #else ( [$e._Bx._Ptr,s8b] ))
參考:
- autoexp.dat入門http://www.thecodeway.com/blog/?p=924
VS2013修改autoexp.dat已經無效,需要修改
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\Visualizers\stl.natvis檔案,大約755-758行
1 <Type Name="std::basic_string<char,*>">2 <DisplayString Condition="_Myres < _BUF_SIZE">{_Bx._Buf,s8}</DisplayString>3 <DisplayString Condition="_Myres >= _BUF_SIZE">{_Bx._Ptr,s8}</DisplayString>4 <StringView Condition="_Myres < _BUF_SIZE">_Bx._Buf,s8</StringView>5 <StringView Condition="_Myres >= _BUF_SIZE">_Bx._Ptr,s8</StringView>
Visual Studio 2010/2013 UTF8編碼調試時顯示中文