1

I would like to know in what encryption should I encode my data and why. First of all, I use GET method because it is search engine inside website. Second, I use RTL language (hebrew). And third which basically is why I ask this question - Firefox and Safari (as I understand it) encode and decode urls automatically. So if I encoded the url, in Firefox I will see it decoded which is good. But if I copy-paste the url to the address bar and than enter the site, Firefox encodes the uncoded url to UTF (I think).

What en/decode should I use? And how can I overcome the Firefox auto en/decode?

3 Answers 3

1

It's unclear exactly what you're asking about; it seems you're confusing concepts of encryption, content encoding, and URL encoding.

I'll assume this is not related to encryption. Regarding content encoding, any modern browser (even IE 6) handles Unicode. As long as your PHP files are encoded as UTF-8 or UTF-16, you should be able to use any Hebrew language code points you'd like. Most web servers when serving up PHP will look at the encoding of the source file and use that in the content type of the pages that are served up, but if you want to be safe, you can explicitly have your PHP send content encoding HTTP headers:

<?php header("Content-Type: text/html; charset=UTF-16"); ?>

As far as URL go, you should URL-encode all URLs and not worry how the browsers will display them in the address bar. A browser will usually (I haven't seen it happen otherwise) URL-encode any invalid characters in an entered address, so even if Firefox decodes a URL in the address bar, pasting it into another browser should still work.

9
  • I am talking about URL-encode. and as I said, firefox encode and decode urls automaticly. If you want to understand better what I am talking about, just use encodeURI in url and than press "enter" in the address bar and you'll see. here's an example I encoded "ש" with encodeURI > "%D7%A9", after I pressed enter > "%F9". somehow I succeed to bypass it by using simple if oO
    – Ron
    Commented Mar 11, 2011 at 1:07
  • Sorry, still not clear on what the issue is. If I paste http://www.google.com/?q=%D7%A9 into Firefox, it displays in the browser as http://www.google.com/?q=ש, but when I copy it and paste again, it still remains as http://www.google.com/?q=%D7%A9. Maybe if you posted your URL encoding/decoding code, this will be clearer to me or future answerers.
    – Jacob
    Commented Mar 11, 2011 at 1:26
  • Jacob, instead of copypaste just focus the address bar and then click enter (when the url is www.google.com/?q=ש)
    – Ron
    Commented Mar 11, 2011 at 1:41
  • The URL remains the same. Which version of Firefox are you using?
    – Jacob
    Commented Mar 11, 2011 at 1:42
  • Firefox version 3.6.15
    – Ron
    Commented Mar 11, 2011 at 1:47
1

Modern browsers are automatically decode URLs before displaying on the location bar, but internally still using the real address which will include two different encodings for the path to the resource and the domain.

When you copy the location from the browser it copy the original address with a purpose to make sure that it would act as a web address when pasted on other applications.

0

You're mixing up a lot of things. But to answer your question: it's good practice to always encode non-ascii / special characters in URLs, so keep doing that. But there's nothing you can do about how browsers handle URLs in the address bar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.