-2

How to convert Strings to unicode? Characters are easy. But if I have "C" stored as a String, how can convert it to unicode? Because for characters, you just can use (int)charvariable but how to do for strings?

Actually I am using String.split() to split a String and then want to check if the 1st character is capital or small. Integer.parseInt is not working. It says NumberFormatException.

Razib
  • 10,965
  • 11
  • 53
  • 80
Anurag
  • 9
  • 2
  • possible duplicated [link](http://stackoverflow.com/questions/5733931/java-string-unicode-value) – Sergio Martinez May 01 '14 at 15:16
  • 2
    What do you mean "convert to unicode"? Strings are already unicode in Java. If you just want to know whether the first character is uppercase, you can use `Character.isUpperCase(theString.charAt(0))`. – yshavit May 01 '14 at 15:34
  • @yshavit: Thanks a lot man..! Will surely try that. But for the time being charAt idea of Razib has done my job. – Anurag May 01 '14 at 15:44

1 Answers1

-1

You may try this -

byte[] bytes = new byte[10];

String str = new String(bytes, Charset.forName("UTF-8"));

System.out.println(str);

for more detail you can see this tutorial

and for checking the first character you my use str.CharAt(0)

Razib
  • 10,965
  • 11
  • 53
  • 80