php equivalent of percent escape + UTF8

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bsharp42
Forum Newbie
Posts: 6
Joined: Sun Aug 02, 2009 12:30 am

php equivalent of percent escape + UTF8

Post by bsharp42 »

Hello,

I have an iphone app which uses a website of mine.
In iphone I convert a search query into


[search_Query.text stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]

Following is the declaration of stringByAdding.....
Returns a representation of the receiver using a given encoding to determine the percent escapes necessary to convert the receiver into a legal URL string.

- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding
Parameters

encoding

The encoding to use for the returned string.

Return Value

A representation of the receiver using encoding to determine the percent escapes necessary to convert the receiver into a legal URL string. Returns nil if encoding cannot encode a particular character
and the NSUTF8stringEncdoing is the Mac/obj-c equivalent of UTF8stringencoding I believe.

Anyway, my question is, is there a way to convert a php string into a string with Percent Escapes using UTF8 encoding
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: php equivalent of percent escape + UTF8

Post by cpetercarter »

Use urlencode(). Have a look at http://uk3.php.net/urlencode, especially the top comment.
Post Reply