convert a byte[] with 8bit latin 1 to java string avoid new String(bytes) because it is using system specific character encoding.
(byte[] value)
| 315 | * avoid new String(bytes) because it is using system specific character encoding. |
| 316 | */ |
| 317 | public static String bytesToString(byte[] value) { |
| 318 | try { |
| 319 | return new String(value, "ISO-8859-1"); |
| 320 | } catch (UnsupportedEncodingException e) { |
| 321 | // can't happen: Latin 1 is a standard encoding |
| 322 | return null; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | /** Helper method that savely handles the null termination of old C String data. */ |
| 327 | public static String CtoJava(String old) { |