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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:06:06+00:00 2026-05-11T07:06:06+00:00

I am currently trying to put together an URL where I specify some GET

  • 0

I am currently trying to put together an URL where I specify some GET parameters. But I want to use japanese or other characters too in this URL.

Is there a way to convert a NSString to a string containing the HTML entities for the ‘special’ characters in my NSString?

I am currently using the following code, which seems to work, except for ‘special characters’ like chinese and japanese:

NSString* url = @'/translate_a/t?client=t&sl=auto&tl='; url = [url stringByAppendingString:destinationLanguage]; url = [url stringByAppendingString:@'&text=']; url = [url stringByAppendingString:text];  NSURL* nsurl = [[NSURL alloc] initWithScheme:@'http' host:@'translate.google.com' path:url];   NSError* error; NSString* returnValue = [[NSString alloc] initWithContentsOfURL:nsurl encoding:NSUTF8StringEncoding error:&error]; 
  • 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. 2026-05-11T07:06:06+00:00Added an answer on May 11, 2026 at 7:06 am

    To properly URL encode your parameters, you need to convert each name and value to UTF-8, then URL encode each name and value separately, then join names with values using ‘=’ and name-value pairs using ‘&’.

    I generally find it easier to put all the parameters in an NSDictionary, then build the query string from the dictionary. Here’s a category that I use for doing that:

    // file NSDictionary+UrlEncoding.h #import <Cocoa/Cocoa.h>  @interface NSDictionary (UrlEncoding)  -(NSString*) urlEncodedString;  @end   // file NSDictionary+UrlEncoding.m #import 'NSDictionary+UrlEncoding.h'  // private helper function to convert any object to its string representation static NSString *toString(id object) {   return [NSString stringWithFormat: @'%@', object]; }  // private helper function to convert string to UTF-8 and URL encode it static NSString *urlEncode(id object) {   NSString *string = toString(object);   return [string stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; }   @implementation NSDictionary (UrlEncoding)  -(NSString*) urlEncodedString {   NSMutableArray *parts = [NSMutableArray array];   for (id key in self) {     id value = [self objectForKey: key];     NSString *part = [NSString stringWithFormat: @'%@=%@',                       urlEncode(key), urlEncode(value)];     [parts addObject: part];   }   return [parts componentsJoinedByString: @'&']; }  @end 

    The method build an array of name-value pairs called parts by URL encoding each key and value, then joining them together with ‘=’. Then the parts in the parts array are joined together with ‘&’ characters.

    So for your example:

    #import 'NSDictionary+UrlEncoding.h' // ... NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; [parameters setValue: @'t' forKey: @'client']; [parameters setValue: @'auto' forKey: @'sl']; [parameters setValue: destinationLanguage forKey: @'tl']; [parameters setValue: text forKey: @'text']; NSString *urlString = [@'/translate_a/t?' stringByAppendingString: [parameters urlEncodedString]]; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I currently use the following: $.ajax({ type: GET, url: file.php, success: function(html) {
I'm currently fighting a fierce battle with an interface I'm trying to put together.
Having some trouble trying to put together a page where images are placed properly.
I am currently trying to put together a simple Illustrator plugin, and coming from
I'm currently trying to put together a rich text editor that includes widgets from
Good evening guys! I'm currently trying to put together a CloudFlare client for the
I am currently trying to put together a model structure for performing various calculations,
I've just recently started dabbling in HTML5/Javascript, and am currently trying to put together
Im currently trying to downlaod a audio track from a WCF, i need some
Im currently trying to learn some stuff about encryption, it's algorithms and how 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.