MBCS to Unicode conversion in swprintf - by fnqbruce

Status : 

  Duplicate<br /><br />
		This item appears to be a duplicate of another existing Connect or internal item.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 1039772 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/25/2014 7:44:03 PM
Access Restriction Public

Description

In older versions of VS, narrow strings could be converted to wide within *printf functions by using %S (upper case S), e.g.:

#define _CRT_NON_CONFORMING_SWPRINTFS
wchar_t awchBuf[1024];
swprintf(awchBuf, L"string is %S", "abc");

In VS2015 Preview, a lower-case s must be used for the same effect, e.g.:

#define _CRT_NON_CONFORMING_SWPRINTFS
wchar_t awchBuf[1024];
swprintf(awchBuf, L"string is %s", "abc");

This is inconsistent with older versions, and contradicts the documentation at http://msdn.microsoft.com/en-us/library/hf4y5e3w.aspx.
Sign in to post a comment.
Posted by Microsoft on 12/2/2014 at 4:21 PM
Hello fnqbruce,

In the Visual Studio "14" CTPs and Visual Studio 2015 Preview (same major release), we made several modifications to the CRT to support C99. The change to format specifiers for *wprintf functions was one of those changes. The change in behavior is described in the following blog post that accompanied the VS "14" CTP1 release.

http://blogs.msdn.com/b/vcblog/archive/2014/06/18/crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1.aspx

The change in behavior brought *wprintf behavior in-line with ISO C (C99), but was a breaking change when compared to legacy behavior for Visual C++.

We have been listening to feedback on this change and are looking at options for helping with this issue in a future VS 2015 release. I've resolved this item as "Duplicate" and we are actively looking into this issue.

-Daniel Griffing
Posted by Microsoft on 11/25/2014 at 8:10 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If you require immediate assistance with this issue, please contact product support at http://support.microsoft.com/ph/1117.