vralfy / phpcsmd

Netbeans plugin to report code measurements generated by phpcs, phpmd, phpcpd and pdepend as Tasks and Annotations
27 stars 6 forks source link

Improve Log output #2

Closed fonsecas72 closed 11 years ago

fonsecas72 commented 11 years ago

I work with ubuntu 12.04 and in my log i get this strange symbol ⊗ whenever a have should have a space. See: Screenshot from 2013-04-03 17:21:53

After google it I've found this and maybe you could use it:

public static String escape(String s) {
    StringBuilder builder = new StringBuilder();
    boolean previousWasASpace = false;
    for( char c : s.toCharArray() ) {
        if( c == ' ' ) {
            if( previousWasASpace ) {
                builder.append(" ");
                previousWasASpace = false;
                continue;
            }
            previousWasASpace = true;
        } else {
            previousWasASpace = false;
        }
        switch(c) {
            case '<': builder.append("&lt;"); break;
            case '>': builder.append("&gt;"); break;
            case '&': builder.append("&amp;"); break;
            case '"': builder.append("&quot;"); break;
            case '\n': builder.append("<br>"); break;
            // We need Tab support here, because we print StackTraces as HTML
            case '\t': builder.append("&nbsp; &nbsp; &nbsp;"); break;  
            default:
                if( c < 128 ) {
                    builder.append(c);
                } else {
                    builder.append("&#").append((int)c).append(";");
                }    
        }
    }
    return builder.toString();
}

from: http://stackoverflow.com/questions/5134959/convert-plain-text-to-html-text-in-java

I've try it and in my pc it works fine.

vralfy commented 11 years ago

ok, i will print the whitespace char but i'm using the ⊗ to detect unprintable characters (such as tabs) to detect possible errors during command call.

fonsecas72 commented 11 years ago

Can the same be done with "," and "*" ?