According to docs for vswprintf: This function Write formatted output using a pointer to a list of arguments.
Does anyone know of functions for native iOS API that can achieve similar effect?
Or, how would you do this?
I know NSString Initwithformat can emulate sprint, but what is the function to emulate vswprintf or even vsprintf?
Thanks
The
NSStringequivalent ofvsprintfisinitWithString:arguments:, like this:There is no separate wide-character version of
NSString. EveryNSStringstores Unicode characters, not bytes. If you have an array of UTF-16 characters, you can use+[NSString stringWithCharacters:length:]to convert it to anNSString.NSStringthinks the%sformat string means an array of one-byte character codes, terminated by a zero byte.NSStringthinks the%Sformat string means an array of two-byte character codes, terminated by two zero bytes.On iOS, a
wchar_tis 4 bytes. I don’t thinkNSStringsupports the%lsformat string for an array ofwchar_t. This documentation doesn’t mention using thelmodifier with thesformat. I looked at theCFFormatCharsTypecase in__CFStringAppendFormatCoreand I don’t think it supports%ls.If you have an array of
wchar_t, and it contains UTF-32 character codes, you can create anNSStringcontaining the same characters like this:If you want to just use
vswprintf, you can; iOS supports it. You need to#include <wchar.h>to get its declaration.