java UTF-8 string

I want to convert a java string that contains UTF-8 characters to a format that a browser can use( the string will be used as URL ) What exactly I mean is that url.openStream() cannot open a webpage, when url contains Persian letters.


Java Strings do not contain UTF-8 characters. From the docs for Character:

The Java 2 platform uses the UTF-16 representation in char arrays and in the String and StringBuffer classes.

You can use the URLEncoder class to encode a string so that url.openStream() works.

You need to percent-encode the non-ASCII characters in the URL. See how to encode URL to avoid special characters in java and URLEncoder#encode(String, String).

Need Your Help

Double slash in OsCommerce shop (e.g.

configuration oscommerce slash shop

The shop version is osCommerce Online Merchant v2.2 RC2a. If a user surfes in the shop, the URL has a double slash before index.php. I looked in the config but cannot find an error.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.