private static String spliceString(String str, int i, int length, String replacement) {
    return str.substring(0, i) + replacement + str.substring(i + length);
  }
Escapes the string for AST; doesn't enclose it in quotes, however.
ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java