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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:14:03+00:00 2026-05-16T17:14:03+00:00

The title pretty much sums it up. I have a hebrew-containing String used in

  • 0

The title pretty much sums it up. I have a hebrew-containing String used in a NSUrl:

NSString * urlS = @"http://irrelevanttoyourinterests/some.aspx?foo=bar&this=that&Text=תל אביב"

I would like to convert in into:

Text=%u05EA%u05DC%20%u05D0%u05d1%u05d9%u05d1

and then send it as a GET request.
I have tried many encoding methods unsuccessfully, and eventually I tried statically inserting the encoded string into the URL, quoted above.

NSURL *url1 = [NSURL URLWithString:urlS];

Then I use startAsyncLoad which you may be familiar with (here), but when the URL is constracted with the static Unicode string, nothing gets sent (checked with Wireshark), although if I use the following line before the startAsyncLoad it sends (wrongly encoded, of course).

urlS = [urlS stringByAddingPercentEscapesUsingEncoding:NSWindowsCP1254StringEncoding];

Thanks 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-16T17:14:04+00:00Added an answer on May 16, 2026 at 5:14 pm

    The percent escapes that you have given as an example are Unicode code points. This type of encoding is non-standard, so I think it is unlikely that there exists a method already that can do this. You may have to roll your own, but it’s not too difficult.

    In a header (perhaps called NSString+NonStandardPercentEscapes.h) put the following:

    #import <Foundation/Foundation.h>
    
    @interface NSString (NonStandardPercentEscapes)
    - (NSString *) stringByAddingNonStandardPercentEscapes;
    @end
    

    And, in a source file (perhaps called NSString+NonStandardPercentEscapes.m) put the following:

    #import "NSString+NonStandardPercentEscapes.h"
    
    @implementation NSString (NonStandardPercentEscapes)
    
    - (NSString *) stringByAddingNonStandardPercentEscapes
    {
        NSCharacterSet *mustEscape = [NSCharacterSet characterSetWithCharactersInString:@"<>~\"{}|\\-`^% "];
        NSMutableString *result = [[NSMutableString alloc] init];
    
        NSUInteger length = [self length];
        unichar buffer[length];
    
        [self getCharacters:buffer range:NSMakeRange(0, length)];
    
        for (NSUInteger i = 0; i < length; i++)
        {
            if ([mustEscape characterIsMember:buffer[i]])
                [result appendFormat:@"%%%02hhx", buffer[i]];
            else if (buffer[i] > 0xFF)
                [result appendFormat:@"%%u%04hx", buffer[i]];
            else if (!isascii((int)buffer[i]))
                [result appendFormat:@"%%%02hhx", buffer[i]];
            else
                [result appendFormat:@"%c", buffer[i]];
        }
    
        // return the mutable version, nobody will know unless they check the class
        return [result autorelease];
    
        // alternatively, you can force the result to be immutable
        NSString *immutable = [[result copy] autorelease];
        [result release];
        return immutable;
    }
    @end
    

    Then, wherever you need to encode your Hebrew string, you can do the following (as long as your source file includes the above header):

    NSString * urlS = @"http://irrelevanttoyourinterests/some.aspx?foo=bar&this=that&Text=תל אביב";
    urlS = [urlS stringByAddingNonStandardPercentEscapes];
    
    NSUrl *url1 = [NSURL URLWithString:urlS];
    

    Disclaimer:

    I have no idea what characters need to be escaped and at what point the escaping should start (this just encodes the entire URL which is probably not what you want), but the above code should at least get you under way.

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

Sidebar

Related Questions

Pretty much what the title says really. We have some code that is .NET
Title pretty much sums it up. The external style sheet has the following code:
The title pretty much says it all. Some caveats are: I need to be
The title pretty much says it all. When I'm doing some reflection through my
The Title pretty much sums up my question. Why can't the following be done
The title pretty much sums it up, and I'm sure there's a perfectly valid
Yep -- the title pretty much sums it up. I've got quite a few
Title pretty much sums it up. Is there a technical name given to a
The title pretty much sums up the gist. I'm interested in whether it is
The title pretty much sums it up - its the easiest thing in the

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.