| | |
| | | public static String escapeSpecialCharacters(String input) { |
| | | input = input.replace("'", "''"); // 转义单引号 |
| | | input = input.replace("\"", "\\\""); // 转义双引号 |
| | | input = input.replace("%", "\\%"); // 转义百分号 |
| | | input = input.replace("_", "\\_"); // 转义下划线 |
| | | input = input.replace("\\", "\\\\"); // 转义反斜杠 |
| | | return input; |
| | | } |
| | | |
| | | public static String unescapeSpecialCharacters(String input) { |
| | | input = input.replace("''", "'"); // 反转义单引号 |
| | | input = input.replace("\\\"", "\""); // 反转义双引号 |
| | | input = input.replace("\\%", "%"); // 反转义百分号 |
| | | input = input.replace("\\_", "_"); // 反转义下划线 |
| | | input = input.replace("\\\\", "\\"); // 反转义反斜杠 |
| | | return input; |
| | | } |
| | | |