1

Hey guys, I have question about urlencode and rawurlencode...

I tested them out and they produce different result like firefox & some online encoders...

Example;

Firefox & encoders

ä = %C3%A4
ß = %C3%9F

PHP rawurlencode & urlencode

ß = %DF

ä = %E4

Anyone got some idea except hard-coding and replacing?

Cheers

king
  • 25
  • 3
  • 2
    You need to understand *why* you are seeing this, otherwise "fixing" the problem is only going to result in problems later. See http://stackoverflow.com/q/1549213/50079. – Jon May 07 '11 at 12:46

2 Answers2

3

They produce different outputs because you provided different inputs, i.e. different character encodings: Firefox uses UTF-8 and your PHP script uses Windows-1252. Although in both character sets the characters are at the same position (ß=0xDF, ä=0xE4), i.e. the have the same code point, they encode that code point differently:

 CP   | UTF-8  | Windows-1252
------+--------+--------------
 0xDF | 0xC39F |         0xDF
 0xE4 | 0xC3A4 |         0xE4

Use the same character encoding (preferably UTF-8) and you’ll get the same result.

Gumbo
  • 620,600
  • 104
  • 758
  • 828
  • Thanks gumbo it worked. $str = "hehe näturlich ß"; $out = iconv('ISO-8859-2', 'UTF-8', $str); echo rawurlencode($out); produced result i want... thank you – king May 07 '11 at 13:29
0

maybe base64 encode, and use in post, to not make visitors afraid of this URL's? Arsen

publikz.com
  • 918
  • 1
  • 12
  • 21