On 30 December 2011 05:23, Kai Tietz wrote:
> 2011/12/30 JonY:
>> Thanks for the bug report, will investigate.
>
> Hmm, not sure if this is related to swprintf and mingw-POSIX variant.
> I would assume the bug here is the use of %s for a wide-string. Using
>
>   wcscpy(test, TEXT("test"));
>   swprintf(teststr, TEXT("This is a %ws"), test);
>
> Works as desired.

Hrm, doesn't work for me.  With this method I see "This is a %ws"
(i.e. the %ws isn't interpreted).  The %s always worked for me in the
past as well (and FWIW, the MSDN documentation says the %s should work
for wide strings when used with swprintf).

However, this did trigger a thought which does fix the issue.  Using
'%S' as opposed to '%s' works.  According to MSDN '%S' can be used for
wide strings with sprintf.  It also explains the behaviour I am
experiencing (as per
http://msdn.microsoft.com/en-us/library/hf4y5e3w.aspx):

s: When used with printf functions, specifies a single-byte–character
string; when used with wprintf functions, specifies a wide-character
string. Characters are displayed up to the first null character or
until the precision value is reached.

S: When used with printf functions, specifies a wide-character string;
when used with wprintf functions, specifies a single-byte–character
string. Characters are displayed up to the first null character or
until the precision value is reached.

So it would seem that somehow sprintf and swprintf are inverted?

What's confusing me even more is that in my larger project where I'm
experiencing the issue, I don't explicitly define
__MINGW_USE_ANSI_STDIO yet I'm experiencing the behaviour I describe.
I've tried adding -U__MINGW_USE_ANSI_STDIO to the compile command but
it didn't help.

Chris

-- 
Chris Sutcliffe
http://emergedesktop.org
http://www.google.com/profiles/ir0nh34d

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to