Created
November 2, 2013 06:41
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | |
* @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