Menu - Top - Home - Donate to Me


NuGet Status Maven Central

Download source code: ZIP file

If you like this software, consider donating to me at this link:

A portable library in C# and Java that implements character encodings used in Web pages and email.

It implements the Encoding Standard, which is currently a candidate recommendation at the time of this writing.

How to Install

The C# implementation is available in the NuGet Package Gallery under the name PeterO.Encoding. To install this library as a NuGet package, enter Install-Package PeterO.Encoding in the NuGet Package Manager Console.

The Java implementation is available as an artifact in the Central Repository. To add this library to a Maven project, add the following to the dependencies section in your pom.xml file:


In other Java-based environments, the library can be referred to by its group ID (com.github.peteroupc), artifact ID (encoding), and version, as given above.


See the Java API documentation.

See the C# (.NET) API documentation.


In C#.

    // Reads text from a UTF-8/UTF-16/UTF-32 file
    public static string ReadTextFromFile(string filename) {
      using (var stream = new FileStream(filename, FileMode.Open)) {
        return new CharacterReader(stream, 2).InputToString();
    // Reads text from a SHIFT-JIS stream, but uses UTF-8/UTF-16
    // instead if it detects byte order marks
      using (var stream = new FileStream(filename, FileMode.Open)) {
        return Encodings.GetEncoding("shift-jis")
    // Writes text in UTF-8 to a file
      using (var stream = new FileStream(filename, FileMode.Create)) {
        var str="Hello world!"


Version 0.3.2:

Version 0.3.1:

Version 0.3:

Version 0.2.1:

Version 0.2.0:

Version 0.1.0:


Written by Peter O. in 2015.

Any copyright is dedicated to the Public Domain.

If you like this, you should donate to Peter O. at: