Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8314665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:53:46+00:00 2026-06-08T20:53:46+00:00

According to docs for vswprintf: This function Write formatted output using a pointer to

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:53:48+00:00Added an answer on June 8, 2026 at 8:53 pm

    The NSString equivalent of vsprintf is initWithString:arguments:, like this:

    // format has type NSString *
    // ap has type va_list
    NSString *formattedString = [[NSString alloc] initWithFormat:format arguments:ap];
    

    There is no separate wide-character version of NSString. Every NSString stores Unicode characters, not bytes. If you have an array of UTF-16 characters, you can use +[NSString stringWithCharacters:length:] to convert it to an NSString.

    NSString thinks the %s format string means an array of one-byte character codes, terminated by a zero byte.

    NSString thinks the %S format string means an array of two-byte character codes, terminated by two zero bytes.

    On iOS, a wchar_t is 4 bytes. I don’t think NSString supports the %ls format string for an array of wchar_t. This documentation doesn’t mention using the l modifier with the s format. I looked at the CFFormatCharsType case in __CFStringAppendFormatCore and 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 an NSString containing the same characters like this:

    wchar_t *wchars = ...;
    unsigned int wcharCount = ...; // number of characters pointed to by wchars
    
    NSString *string = [[NSString alloc] initWithBytes:(const void *)wchars
        length:wcharCount * sizeof *wchars
        encoding:NSUTF32StringEncoding];
    

    If you want to just use vswprintf, you can; iOS supports it. You need to #include <wchar.h> to get its declaration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a System.Windows.Forms.TextBox . According to the docs, the MaxLength property controls the
According to the gcc docs , memcmp is not an intrinsic function of GCC.
According to the Thinking Sphinx docs ... Turning on delta indexing does not remove
According to the docs: A TestCase, on the other hand, does not truncate tables
Using jQuery Autocomplete, according to the docs you have to do the following to
According to the docs: list.append(x): Add an item to the end of the list
I'm using ActionMailer 3.0.7 According to the docs plain text emails are the default.
Using this example from http://docs.python.org/tutorial/classes.html#class-objects : class MyClass: A simple example class i =
According to the docs , using the CENTER attribute will not perform any scaling
According to the docs you can insert objects an any position in a List:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.