On 30/12/2011 13:55, Chris Sutcliffe wrote:
> 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.
The ISO C way is "%ls", and that always works for me (although because
of so many other non-ISO or non-POSIX 'features' I do tend to avoid
msvcrt's *printf, usually in favour of that from the trio project).
> 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
>
--
Brian D. Ripley, [email protected]
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
------------------------------------------------------------------------------
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