I ran a few javascript files thru my spaces2tabs converter (ps I was porting to coffeescript which is why I needed tabs – have since abandoned coffeescript)
public static String convertSpacesToTabs(String str, int spacesPerTab) {
assert (spacesPerTab >= 1);
StringBuilder builder = new StringBuilder();
for (int i = 0; i = 0) {
//System.out.println("old: " + oldIdx + " new: " + newIdx);
sb.append(str.substring(oldIdx, newIdx));
sb.append('\t');
oldIdx = newIdx + toFind.length();
newIdx = str.indexOf(toFind, oldIdx);
}
sb.append(str.substring(oldIdx, str.length()));
return sb.toString();
}
Worked like a charm: replaced spaces with tabs. Looks perfect in TextMate, runs fine, etc etc. Perfectly valid UTF-8
The ONLY issue comes up in eclipse, where it is a mess.
It seems like eclipse cannot deal with the \t’s I inserted. When initially opening the files, eclipse shows a strange character and flags these tabs with the message “Invalid Character” delete this token. When I go to the project properties under Resource I changed text version to utf-8 and the strange characters go away, but the error message doesn’t!
Is there an easy way to make eclipse happy?
Seems like a bug in eclipse… no fix as far as I’m aware…