How to correct URI?

Hello everyone!

How to correct URI? For example I have URI:

http://www.angool.com/search/index.php?query=word word

and I want to have:

http://www.angool.com/search/index.php?query=word+word

How do this? You know some function?

[325 byte] By [JavaCranea] at [2007-11-27 6:08:55]
# 1
> How do this? You know some function?String.replace(), maybe (assuming you mean a method in java)? http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
kevjavaa at 2007-7-12 17:11:59 > top of Java-index,Java Essentials,Java Programming...
# 2
java.net.URLEncoder comes to my mind.
quittea at 2007-7-12 17:11:59 > top of Java-index,Java Essentials,Java Programming...
# 3
> java.net.URLEncoder comes to my mind.I was just testing you ;).
kevjavaa at 2007-7-12 17:11:59 > top of Java-index,Java Essentials,Java Programming...
# 4
I have a little problem =)Now URL looks like this:http%3A%2F%2Fwww.angool.com%2Fsearch%2Findex.php%3Fquery%3Dcebula+i+jabut should looks like this: http://www.angool.com/search/index.php?query=cebula+i+ja
JavaCranea at 2007-7-12 17:11:59 > top of Java-index,Java Essentials,Java Programming...
# 5
Don't URL-encode the whole URL, just the parameter values.That means you don't want to take a fully-constructed but faulty URL and try to clean it up. You want to modify the code that constructs the URL so that it URL-encodes the parameter values.
DrClapa at 2007-7-12 17:11:59 > top of Java-index,Java Essentials,Java Programming...
# 6
What character encoding i should use? It must be uniwersally.
JavaCranea at 2007-7-12 17:11:59 > top of Java-index,Java Essentials,Java Programming...
# 7

KarateKid,

> What character encoding i should use? It must be uniwersally.

> uniwersally

Patent that word, wuickly. :-)

Do you mean which character encoding should you use for the URI?

It shouldn't make a dot of difference, because a valid URI should only contain "basic" characters less than 128, which all modern encoding's (excluding EBCDIC) inherited from ASCII ... so all characters in a valid URI should be the same no matter which character set you encode it in.

Is that what you where asking?

I didn't know you could even change the character set for get/post.

Cheers. Keith.

Message was edited by: corlettk

corlettka at 2007-7-12 17:11:59 > top of Java-index,Java Essentials,Java Programming...
# 8

In my country (Poland) we have some characters that don't exist in your language. I want to send some words to web dictionary and there is problem - this dictionary change polish characters on other(I don't know from which country). When I send the same characters to polish site it is't the problem. I use UTF-8. Is it UTF-8 guilt?

JavaCranea at 2007-7-12 17:12:00 > top of Java-index,Java Essentials,Java Programming...
# 9

> In my country (Poland)

Ah. This explains the w.

> we have some characters that

> don't exist in your language. I want to send some

> words to web dictionary and there is problem - this

> dictionary change polish characters on other(I don't

> know from which country). When I send the same

> characters to polish site it is't the problem. I use

> UTF-8. Is it UTF-8 guilt?

Who is doing this changing the characters though? You have no control over what charset the site is using or is expecting.

So. How are you connecting/sending this data? Why do you think that

the site in question will support your characters?

cotton.ma at 2007-7-12 17:12:00 > top of Java-index,Java Essentials,Java Programming...
# 10

> I didn't know you could even change the character set

> for get/post.

[url=http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLEncoder.html#encode(java.lang.String, java.lang.String)]http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLEncoder.html#encode(java.lang.String, java.lang.String)[/url]

2nd string specifies encoding.

Although the following comment bears noting.

Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.

cotton.ma at 2007-7-12 17:12:00 > top of Java-index,Java Essentials,Java Programming...
# 11

Craney,

I doubt the UTF-8 character encoding is to blame here. I also doubt that foreign websights will (ever) deal with uniquely polish characters... and (forgive me) I really don't think it's reasonable to expect them to.

> When I send the same characters to polish site it is't the problem

I presume that there is no (free) polish dictionary site? Have you looked hard for one?

Yeah, I think you're stuck here, as long as you need the polish characters you're stuck using polish sites.

Keith.

corlettka at 2007-7-12 17:12:00 > top of Java-index,Java Essentials,Java Programming...
# 12
www.angool.com is polish site. When i write some polish characters in form it is't a problem, it translate, but when I open browser witch http://www.angool.com/search/index.php?query=polish_characters, then these character are changed. Why? =(
JavaCranea at 2007-7-12 17:12:00 > top of Java-index,Java Essentials,Java Programming...
# 13
OK, thanks everyone. After my observations I think that it's this site's guilt. I think that, because on other polish sites this problem doesn't exists.One more time thanks =)
JavaCranea at 2007-7-12 17:12:00 > top of Java-index,Java Essentials,Java Programming...