Mercurial > 510Connectbot
comparison src/ch/ethz/ssh2/util/StringEncoder.java @ 342:175c7d68f3c4
merge ganymed into mainline
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 31 Jul 2014 16:33:38 -0700 |
parents | 071eccdff8ea |
children |
comparison
equal
deleted
inserted
replaced
272:ce2f4e397703 | 342:175c7d68f3c4 |
---|---|
1 /* | |
2 * Copyright (c) 2006-2011 Christian Plattner. | |
3 * All rights reserved. | |
4 * Please refer to the LICENSE.txt for licensing details. | |
5 */ | |
6 package ch.ethz.ssh2.util; | |
7 | |
8 import java.io.UnsupportedEncodingException; | |
9 | |
10 /** | |
11 * @author Christian Plattner | |
12 * @version $Id: StringEncoder.java 43 2011-06-21 18:34:06Z dkocher@sudo.ch $ | |
13 */ | |
14 public class StringEncoder { | |
15 public static byte[] GetBytes(String data) { | |
16 try { | |
17 return data.getBytes("UTF-8"); | |
18 } | |
19 catch (UnsupportedEncodingException e) { | |
20 throw new RuntimeException(e); | |
21 } | |
22 } | |
23 | |
24 public static String GetString(byte[] data) { | |
25 return GetString(data, 0, data.length); | |
26 } | |
27 | |
28 public static String GetString(byte[] data, int off, int len) { | |
29 try { | |
30 return new String(data, off, len, "UTF-8"); | |
31 } | |
32 catch (UnsupportedEncodingException e) { | |
33 throw new RuntimeException(e); | |
34 } | |
35 } | |
36 } |