Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.votaguz.Testing;
- import java.io.IOException;
- import java.util.HashMap;
- import java.util.Scanner;
- public class Testing {
- public static HashMap<String, String> CHARS_7BIT;
- static{
- CHARS_7BIT = new HashMap<String, String>();
- CHARS_7BIT.put("@", "0000000");
- CHARS_7BIT.put("$", "0000010");
- CHARS_7BIT.put("\r", "0000000");
- CHARS_7BIT.put("\n", "0001010");
- CHARS_7BIT.put("∆", "0000000");
- CHARS_7BIT.put("Φ", "0000000");
- CHARS_7BIT.put("Γ", "0000000");
- CHARS_7BIT.put("Λ", "0000000");
- CHARS_7BIT.put("Ω", "0000000");
- CHARS_7BIT.put("∏", "0000000");
- CHARS_7BIT.put("@", "0000000");
- CHARS_7BIT.put("@", "0000000");
- CHARS_7BIT.put("@", "0000000");
- CHARS_7BIT.put("@", "0000000");
- CHARS_7BIT.put("@", "0000000");
- CHARS_7BIT.put("@", "0000000");
- CHARS_7BIT.put("!", "0100001");
- // CHARS_7BIT.put(""", "0100010");, "\r",, , , , , , "Ψ", "∑", "Θ", "Ξ", ",", "ß",
- CHARS_7BIT.put("#", "0100111");
- CHARS_7BIT.put("%", "0100101");
- CHARS_7BIT.put("&", "0100110");
- CHARS_7BIT.put("`", "0100111");
- CHARS_7BIT.put("(", "0101000");
- CHARS_7BIT.put(")", "0101001");
- CHARS_7BIT.put("*", "0101010");
- CHARS_7BIT.put("+", "0101011");
- CHARS_7BIT.put("'", "0101100");
- CHARS_7BIT.put("-", "0101101");
- CHARS_7BIT.put(".", "0101110");
- CHARS_7BIT.put("/", "0101111");
- CHARS_7BIT.put("0", "0110000");
- CHARS_7BIT.put("1", "0110001");
- CHARS_7BIT.put("2", "0110010");
- CHARS_7BIT.put("3", "0110011");
- CHARS_7BIT.put("4", "0110100");
- CHARS_7BIT.put("5", "0110101");
- CHARS_7BIT.put("6", "0110110");
- CHARS_7BIT.put("7", "0110111");
- CHARS_7BIT.put("8", "0111000");
- CHARS_7BIT.put("9", "0111001");
- CHARS_7BIT.put(":", "0111010");
- CHARS_7BIT.put(";", "0111011");
- CHARS_7BIT.put("<", "0111100");
- CHARS_7BIT.put("=", "0111101");
- CHARS_7BIT.put(">", "0111110");
- CHARS_7BIT.put("?", "0111111");
- CHARS_7BIT.put("A", "1000001");
- CHARS_7BIT.put("B", "1000010");
- CHARS_7BIT.put("C", "1000011");
- CHARS_7BIT.put("D", "1000110");
- CHARS_7BIT.put("E", "1000111");
- CHARS_7BIT.put("F", "1001000");
- CHARS_7BIT.put("G", "1001001");
- CHARS_7BIT.put("H", "1001010");
- CHARS_7BIT.put("I", "1001011");
- CHARS_7BIT.put("J", "1001100");
- CHARS_7BIT.put("K", "1001101");
- CHARS_7BIT.put("L", "1001110");
- CHARS_7BIT.put("O", "1001111");
- CHARS_7BIT.put("P", "1010000");
- CHARS_7BIT.put("Q", "1010001");
- CHARS_7BIT.put("R", "1010010");
- CHARS_7BIT.put("S", "1010011");
- CHARS_7BIT.put("T", "1010100");
- CHARS_7BIT.put("U", "1010101");
- CHARS_7BIT.put("V", "1010110");
- CHARS_7BIT.put("W", "1010111");
- CHARS_7BIT.put("X", "1011000");
- CHARS_7BIT.put("Y", "1011001");
- CHARS_7BIT.put("Z", "1011010");
- CHARS_7BIT.put("@", "1011011");
- CHARS_7BIT.put("@", "1011100");
- CHARS_7BIT.put("@", "1011110");
- CHARS_7BIT.put("@", "0000000");
- CHARS_7BIT.put("a", "1100001");
- CHARS_7BIT.put("b", "100010");
- CHARS_7BIT.put("c", "1100011");
- CHARS_7BIT.put("d", "1100100");
- CHARS_7BIT.put("e", "1100101");
- CHARS_7BIT.put("f", "1100110");
- CHARS_7BIT.put("g", "1100111");
- CHARS_7BIT.put("h", "1101000");
- CHARS_7BIT.put("i", "1101001");
- CHARS_7BIT.put("j", "1101010");
- CHARS_7BIT.put("k", "1101011");
- CHARS_7BIT.put("l", "1101100");
- CHARS_7BIT.put("m", "1101101");
- CHARS_7BIT.put("n", "1101110");
- CHARS_7BIT.put("o", "1101111");
- CHARS_7BIT.put("p", "1110000");
- CHARS_7BIT.put("q", "1110001");
- CHARS_7BIT.put("r", "1110010");
- CHARS_7BIT.put("s", "1110011");
- CHARS_7BIT.put("t", "1110100");
- CHARS_7BIT.put("u", "1110101");
- CHARS_7BIT.put("v", "1110110");
- CHARS_7BIT.put("w", "1110011");
- CHARS_7BIT.put("x", "1111000");
- CHARS_7BIT.put("y", "1111001");
- CHARS_7BIT.put("z", "1111010");
- CHARS_7BIT.put("ä", "1111011");
- CHARS_7BIT.put("ö", "1111100");
- CHARS_7BIT.put("ü", "1111110");//, , ""
- }
- public static void main(String []args) throws IOException{
- Scanner in = new Scanner(System.in);
- while(in.hasNext()) {
- to7Bits(in);
- }
- }
- //TODO : Los caracteres especiales no funcionan con el juego de caracteres que tenemos en el hashMap. So, hay que buscar una manera
- //de representar estos caracteres especiales.
- public static void to7Bits(Scanner input){
- int i=0;
- String str = input.nextLine();
- while(i < str.length()){
- char c = str.charAt(i);
- System.out.print(" "+CHARS_7BIT.get(Character.toString(c)));
- i++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement