com.sleepycat.utilint
Class StringUtils
java.lang.Object
com.sleepycat.utilint.StringUtils
public class StringUtils
- extends Object
Method Summary |
static String |
fromASCII(byte[] bytes)
|
static String |
fromASCII(byte[] bytes,
int offset,
int len)
|
static String |
fromUTF8(byte[] bytes)
|
static String |
fromUTF8(byte[] bytes,
int offset,
int len)
|
static byte[] |
toASCII(String str)
|
static byte[] |
toUTF8(String str)
In all src and test code, the String(byte[], ...) constructor and
String.getBytes method must always be passed a charset name, to avoid
portability issues. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StringUtils
public StringUtils()
toUTF8
public static byte[] toUTF8(String str)
- In all src and test code, the String(byte[], ...) constructor and
String.getBytes method must always be passed a charset name, to avoid
portability issues. Otherwise, portability issues will occur when
running on a JVM plataform with a non-western default charset, the
EBCDIC encoding (on z/OS), etc. [#20967]
In most cases, the UTF8 or ASCII charset should be used for portability.
UTF8 should be used when any character may be represented. ASCII can be
used when all characters are in the ASCII range. The default charset
should only be used when handling user-input data directly, e.g.,
console input/output or user-visible files.
Rather than using getBytes() and String() directly, the methods here are
used to avoid having to clutter code with a catch for
java.io.UnsupportedEncodingException, which should never be thrown for
the "UTF-8" or "US-ASCII" charsets.
fromUTF8
public static String fromUTF8(byte[] bytes)
fromUTF8
public static String fromUTF8(byte[] bytes,
int offset,
int len)
toASCII
public static byte[] toASCII(String str)
fromASCII
public static String fromASCII(byte[] bytes)
fromASCII
public static String fromASCII(byte[] bytes,
int offset,
int len)
Copyright (c) 2004-2012 Oracle. All rights reserved.