Skip to content

Instantly share code, notes, and snippets.

@ddimtirov
Created November 2, 2013 06:41
Show Gist options
  • Save ddimtirov/7276263 to your computer and use it in GitHub Desktop.
Save ddimtirov/7276263 to your computer and use it in GitHub Desktop.
Simple utility to convert from old Bulgarian DOS cyrillic to Windows 1251 text encoding.
import java.io.*;
/**
* Simple utility to convert from old Bulgarian DOS cyrillic to Windows 1251 text encoding.
* <pre>
* Usage: java Plus64 inputfile outputfile
* </pre>
* @author dimiter@blue-edge.bg
* @since Mar 3, 2003 1:15:33 AM
*/
public class Plus64 {
public static void main(String[] args) throws IOException {
checkUsage(args);
byte[] buf = readFile(args[0]);
for (int i = 0; i < buf.length; i++) if (buf[i] < 0) buf[i] += 64;
writefile(args[1], buf);
}
private static byte[] readFile(String filename) throws IOException {
FileInputStream in = new FileInputStream(filename);
byte[] buf = new byte[in.available()];
in.read(buf);
in.close();
return buf;
}
private static void writefile(String filename, byte[] buf) throws IOException {
FileOutputStream out = new FileOutputStream(filename);
out.write(buf);
out.flush();
out.close();
}
private static void checkUsage(String[] args) {
if (args.length == 2) return;
System.out.println("USAGE: \n\t java Plus64 <inputfile> <outputfile>");
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment