Tuesday, January 13, 2009

Correct encoding of String in Java

Found many examples of correct encoding/decoding of string in Java. Tried many ways, but helped only one. Here is an example of one program. The InputStreamReader reads stream that is encoded in the Cp1251. Program correctly reads and transforms to correct encoding that Java can represent it.

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), "Cp1251"));

rd.readLine(); // Here is the magic :))

If you know Russian, there is a good article about encoding in Java: http://www.jug.ru/servlets/index?page=rus

Read More...

Sunday, January 4, 2009

Google account as OpenID

I am reading a stackoverflow RSS and one post got my attention with an interesting fact.
You can now use Google as an OpenID provider. Before that, Google were not providing OpenID feature directly, and as I mentioned before, you had to use blogger.com as a provider.
But here is what the post say:
For example, one of the newest OpenID providers is Google. If you have a GMail account, just enter this magical OpenID phrase:

google.com/accounts/o8/id

Fine print: yes, eventually Google will support entering gmail.com, just like Yahoo supports using yahoo.com for their OpenIDs. Until then, it’s this crazy string.

I've tried it as usual on livejournal and it worked! :) Halliluya! :) However, just one concern: what if Google will close this link in the future with providing more simple, like gmail.com?

Read More...