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

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The simplest way would be to use .htaccess to forward… May 12, 2026 at 1:18 am
  • Editorial Team
    Editorial Team added an answer I think the best way to do this is via… May 12, 2026 at 1:18 am
  • Editorial Team
    Editorial Team added an answer Use the iteri function: let sequence = Seq.initInfinite (fun _… May 12, 2026 at 1:18 am

Related Questions

I'm hoping someone can help me with a question I have about images and
First question on stackoverflow. I have no previous experience of running a high traffic
I am trying to put a requirement together for a new environment to consist
I have a scenario where I need to put together a script to add

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.