|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microsoft.tfs.core.util.FileEncodingDetector
public final class FileEncodingDetector
Static methods which assist in detecting text encodings in disk files. Always
returns encodings represented by known FileEncoding
instances (which
can be queried for their text names and code page numbers).
Method Summary | |
---|---|
static FileEncoding |
detectEncoding(java.lang.String path,
FileEncoding encodingHint)
Detects the encoding used for a server or local path with hints. |
protected static boolean |
looksLikeANSI(byte[] bytes,
int limit)
Tests whether the given byte array looks like an ANSI text file with the default text encoding, i.e. |
protected static boolean |
looksLikeEBCDIC(byte[] bytes,
int limit)
Tests whether the given byte array looks like an EBCDIC text file (contains character values that would be present in an EBCDIC text file without the control characters that would not). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static FileEncoding detectEncoding(java.lang.String path, FileEncoding encodingHint)
The FileEncoding.AUTOMATICALLY_DETECT
encoding hint is only valid
for local (not server) paths that do not contain wildcard characters,
exist on disk, and are files (not directories). If it is specified for
other kinds of paths, an exception is thrown.
Encoding hints are evaluated in the following way:
FileEncoding.BINARY
that encoding is returned
immediately for all item types.FileEncoding.DEFAULT_TEXT
the default encoding
for this platform is returned immediately for all item types.FileEncoding.AUTOMATICALLY_DETECT
, that encoding is returned
immediately for all item types.FileEncoding.AUTOMATICALLY_DETECT
:
path
- the path to detect encoding for (must not be null
)encodingHint
- the encoding hint (must not be null
)
FileEncoding
that matches the given file's encoding.
TECoreException
- if the specified encoding hint is not valid for the type of path
givenprotected static boolean looksLikeANSI(byte[] bytes, int limit)
bytes
- the bytes to check for ANSI-ness (must not be null
)limit
- the maximum number of bytes to read.
protected static boolean looksLikeEBCDIC(byte[] bytes, int limit)
bytes
- the bytes to check for EBCDIC-ness (must not be null
)limit
- the maximum number of bytes to read.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |