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

  • SEARCH
  • Home
  • 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 6073149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:14:20+00:00 2026-05-23T10:14:20+00:00

I have implemented some code to convert a NSString of text to an NSString

  • 0

I have implemented some code to convert a NSString of “text” to an NSString of (ASCII) ints, like so:

@"Hello" is converted to @"72 101 108 108 111"

However, I am having quite a bit of difficulty doing the opposite. Starting with a string of ints (with the spaces) and converting back to the plain string of text.

What I need: @"72 101 108 108 111" must be converted to @"Hello"

I have tried breaking up the input string into an int array, iterating through it, and using repeatedly the following:

[NSString stringWithFormat:@"%c", decCharArray[i]]

However, the problem with that is that it parses each particular digit into ASCII, converting the 7, the 2, the space, the 1, etc.

Thanks a ton in advance.

  • 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-05-23T10:14:21+00:00Added an answer on May 23, 2026 at 10:14 am

    There is no real magic on it. Since you’ll be using ASCII, to convert an int
    to a char all you have to do is an assignment, as you may already know:

    char a = 65; /* a contains 'A' */
    

    NSString has a very convenient method componentsSeparatedByString: that will
    return an array of strings containing your numbers, and you can get an int
    from a string with the intValue method. Thus, all you have to do is to split
    the string and iterate through the components assigning their int value to a
    char array. Here is an example function that does that:

    NSString *
    TextFromAsciiCodesString (NSString *string)
    {
        NSArray *components = [string componentsSeparatedByString:@" "];
        NSUInteger len = [components count];
        char new_str[len+1];
    
        int i;
        for (i = 0; i < len; ++i)
            new_str[i] = [[components objectAtIndex:i] intValue];
    
        new_str[i] = '\0';
    
        return [NSString stringWithCString:new_str
                                  encoding:NSASCIIStringEncoding];
    }
    

    And a simple use of it, with your "Hello" example:

    NSString *string = @"72 101 108 108 111";
    NSLog(@"%@", TextFromAsciiCodesString(string));
    

    Actually, it’s a bit different as your example was "Hell^K" 🙂

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

Sidebar

Related Questions

I have some .NET remoting code where a factory method, implemented in some server
I have some code like this: public class EffectValues : IEnumerable<object> { public object
I have code that I would like to convert so that I am grabbing
I have some code that uses the shared gateway pattern to implement an inversion
I've been trying to implement unit testing and currently have some code that does
I have already implemented some AJAX pagination in my Rails app by using the
What are some of the ways you have implemented models in the Zend Framework?
I have implemented a simple linux shell in c. Now, I am adding some
I have some REST web services implemented in WCF. I wish to make these
I'm trying to write some code that will take any object and convert it

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.