tags:

views:

45

answers:

3

I have a long url with several values.

Example 1:

http://www.domain.com/list?seach_type[]=0&search_period[]=1&search_min=3000&search_max=21000&search_area=6855%3B7470%3B7700%3B7730%3B7741%3B7742%3B7752%3B7755%3B7760%3B7770%3B7800%3B7840%3B7850%3B7860%3B7870%3B7884%3B7900%3B7950%3B7960%3B7970%3B7980%3B7990%3B8620%3B8643%3B8800%3B8830%3B8831%3B8832%3B8840%3B8850%3B8860%3B8881%3B9620%3B9631%3B9632

My variable search area contains only 4 number digits (example 4000, 5000), but can contain a lot of them. Right now I seperate these in the URL by using ; as separator symbol. Though as seen in Example 1, the ; is converted into %3B. This makes me believe that this is a bad symbol to use.

What is the best url separator?

+3  A: 

If there are only numbers to separate, you have a large choice of separators. You can choose any letter for example.

Probably a space can be a good choice. It will be transformed into + character in the URL, so will be more readable than a letter.

Example: search_area=4000+5000+6000

MainMa
A: 

Well, according to RFC1738, valid URLs may only contain the letters a-z, the plus sign (+), period and hyphen (-).

Generally I would go with a plus to separate your search areas. So your your URL would become http://www.domain.com/list?seach_type=0&search_period=1&search_min=3000&search_max=21000&search_area=6855+7470+7700+...

--EDIT--

As GinoA pointed out I misread the document. Hence "$-_.+!*'()," are valid characters too. I'd still go with the + sign though.

moontear
-1. This is incorrect, as GinoA points out.
You
You're right (or GinoA is). I edited the answer.
moontear
+1  A: 

Moontear, I think you have misread the linked document. That limitation only applies to the "scheme" portion of the URL. In the case of WWW URLs, that is the "http".

The next section of the document goes on to say:

Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.

I'd personally use comma (,). However, plus (+) and dash (-) are both reasonable options as well.

BTW, that document also mentions that semi-colon (;) is reserved in some schemes.

GinoA
-1. This should be a comment — SO is not a forum!
You
@You: I disagree with the downvote. It's not just a comment, but also a valid answer, more explicit than mine. Especially the last two paragraphs.
MainMa
@MainMa: Somewhat true. I'd rephrase it if I were GinoA; as it is now, it's a reply — and those belong in comments.
You