Get first printable character from a string

118 Views Asked by At

This might seem like an already answered question, but I couldn't find it anywhere.

How do I get the first printable character in Java?

For example

abcd    //should return "a" - The first printable char is of 1 bytes
     //should return "" - The first printable char is of 4 bytes (2 codepoints)
"".length() //2 - I guess thats because of 2 codepoints
☠☠     //should return ☠ - The first printable char is of 1 bytes
     //should return  - The first printable char is of 8 bytes (4 codepoints)
abcd   //should return  - The first printable char is of 8 bytes (4 codepoints)
0

There are 0 best solutions below