C++ Logo

std-discussion

Advanced search

Re: Portable unicode string and missing snwprintf function

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Thu, 17 Nov 2022 21:24:27 +0100
On 17/11/2022 21.04, Nicolas M via Std-Discussion wrote:
> Sure you can use streams to format std::wstring, but it is a different feature.
>
> Emulation of snwprintf in our programs results in inefficient code, I think the standard library should be symmetric and contain both snprintf and snwprintf.

snwprintf is spelled swprintf

Jens


>
> Le jeu. 17 nov. 2022, 20:35, William Linkmeyer <wlink10_at_[hidden] <mailto:wlink10_at_[hidden]>> a écrit :
>
> std::wcout
>
> WL
>
>> On Nov 17, 2022, at 8:39 AM, Nicolas M via Std-Discussion <std-discussion_at_[hidden] <mailto:std-discussion_at_[hidden]>> wrote:
>>
>> 
>> Hello,
>>
>> While porting some Microsoft C++ code to the Linux platform, I have realized that while there is snprintf() function for std::string, there is no direct equivalent for std::wstring.
>>
>> Do you think such a function could be added to the standard? It would make std::wstring a more viable alternative to std::string.
>> https://stackoverflow.com/questions/4107947/how-to-determine-buffer-size-for-vswprintf-under-linux-gcc <https://stackoverflow.com/questions/4107947/how-to-determine-buffer-size-for-vswprintf-under-linux-gcc>
>> https://stackoverflow.com/questions/3693479/why-does-c-not-have-an-snwprintf-function <https://stackoverflow.com/questions/3693479/why-does-c-not-have-an-snwprintf-function>
>>
>> On the other hand, with Windows starting to support UTF-8 programs as of 2019 (and UTF-8 std::string), std::string might become a simple way to store unicode text in cross-platform programs.
>> https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page <https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page>
>>
>> Best Regards
>> --
>> Std-Discussion mailing list
>> Std-Discussion_at_[hidden] <mailto:Std-Discussion_at_[hidden]>
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion <https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion>
>
>

Received on 2022-11-17 20:24:34