Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.HashMap; public class Main { static HashMap<Character, String> h = new HashMap<Character, String>(); public static String escape(String str) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (h.containsKey(c)) { sb.append(h.get(c)); } else { sb.append(c); } } return sb.toString(); } }