Java tutorial
//package com.java2s; public class Main { private final static int begin = 32; private final static int middle = begin + 64; private final static int last = middle + 22; private final static char[] add = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', '1', '2', '3', '4', '5', '6', '7', '8', 'K', 'Q', 'R', 'B', 'N', '=' }; private final static String[] adds = { "O-O", "O-O-O", "1/2-1/2", "1-0", "0-1" }; public static String unzipPgn(String pgn) { StringBuffer buffer = new StringBuffer(); for (int n = 0; n < pgn.length(); n++) { char c = pgn.charAt(n); if (c >= last) { buffer.append(adds[c - last]); buffer.append(' '); } else if (c < middle) { int num = c - begin; buffer.append((char) (num / 8 + 'a')); buffer.append((char) (num % 8 + '1')); if (n != pgn.length() - 1 && pgn.charAt(n + 1) == last - 1) { buffer.append(add[pgn.charAt(++n) - middle]); buffer.append(add[pgn.charAt(++n) - middle]); } buffer.append(' '); } else { buffer.append(add[c - middle]); } } return buffer.toString(); } }