public static String escapeForHtml(String inStr, boolean changeSpace, int tabLength) {\r
StringBuilder retStr = new StringBuilder();\r
int i = 0;\r
+ int l = 0;\r
+ \r
while (i < inStr.length()) {\r
if (inStr.charAt(i) == '&') {\r
retStr.append("&");\r
} else if (changeSpace && inStr.charAt(i) == ' ') {\r
retStr.append(" ");\r
} else if (changeSpace && inStr.charAt(i) == '\t') {\r
- for (int j = 0; j < tabLength; j++) {\r
+ for (int j = 0; j < tabLength - l; j++) {\r
retStr.append(" ");\r
}\r
+ l = -1;\r
} else {\r
retStr.append(inStr.charAt(i));\r
}\r
+ \r
+ l = (l + 1) % tabLength;\r
+ if (inStr.charAt(i) == '\n')\r
+ l = 0;\r
i++;\r
}\r
return retStr.toString();\r