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 6139509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:59:55+00:00 2026-05-23T17:59:55+00:00

a noob question here. I am trying to make an automatic search and replace

  • 0

a noob question here.

I am trying to make an automatic search and replace process for characters’ ASCII values in a string.

so, I have a string constructed from a content of a UITextField

NSString *searchText;
searchText = (mmText.text);

then I do a little loop and check all entered characters for their ASCII values. if they’re not in the allowed range I want to search and replace them with something else (? for now)

so let’s say I am in the loop and I get to a ASCII 45 character (it’s a minus sign):

int asciiCode = 45;

now I would like to find the ASCII 45 character in the string and replace it with a question mark

This is what I am doing at the moment:

 NSString *ascStr = [NSString stringWithFormat:@"%c", asciiCode];
 NSRange matchSpace;
 matchSpace = [searchText rangeOfString: ascStr];
 if (matchSpace.location == NSNotFound)
 {}
 else   
 NSMutableString *searchandReplace = [NSMutableString stringWithString: searchText];
 [searchandReplace replaceCharactersInRange: [searchandReplace rangeOfString: ascStr] withString: @"?"];
  mmText.text = searchandReplace;
  }

This works fine for a regular ASCII value (0-255), but it doesn’t seem to work for the extended ASCII values coming from foreign languages. For example when using the Korean language mode, one of the main character looks like a double crossed W, but when printed via NSLog it looks like a copyright sign. This is probably the reason the search and replace procedure doesn’t work for it. It has an ASCII value of 8361.

any ideas ? thank you!

  • 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-23T17:59:55+00:00Added an answer on May 23, 2026 at 5:59 pm

    it turns out it was as simple as changing:

    NSString *ascStr = [NSString stringWithFormat:@"%c", asciiCode];
    

    to

    NSString *ascStr = [NSString stringWithFormat:@"%C", asciiCode];
    

    %c
    8-bit unsigned character (unsigned char), printed by NSLog() as an ASCII character, or, if not an ASCII character, in the octal format \ddd or the Unicode hexadecimal format \udddd, where d is a digit

    %C
    16-bit Unicode character (unichar), printed by NSLog() as an ASCII character, or, if not an ASCII character, in the octal format \ddd or the Unicode hexadecimal format \udddd, where d is a digit

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

Sidebar

Related Questions

No related questions found

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.