Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

io.charset


    1  Packaging
    2  Usage
    3  See also

The charset package contains classes which work with the Java charset package. It allows to guess the encoding of a file.

Note that there is no way to get the encoding of a file except by guessing. Nothing in a file explictly set its encoding.

Packaging

The io.charset package is derived from a small part of the code of the Java ICU project (version 58.2). It is licensed under the ICU license, which is compatible with the BSD license.

Usage

To guess the encoding of a particular file, you can use one of the following methods: The CharsetMatch.getName() method allows to get the name of the charset. The CharsetMatch.getConfidence() method gives the confidence of the match.

The result can be used in all Java methods which uses a charset, such as for example String.getBytes(String). See for example the StringUtils.escapeString(String) method which escapes Strings encoded in a particular charset.

See also


Categories: io | packages

Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences