code: public static String normalizeChar(char c, boolean canonical)
     {
  
        switch (c)
        {
           case '<' :
              return "&lt;";
           case '>' :
              return "&gt;";
           case '&' :
              return "&amp;";
           case '"' :
              return "&quot;";
           case '\'' :
              return "&apos;";
           case '\r' :
              if (canonical)
                 return "_x000D_";
           case '\n' :
              if (canonical)
                 return "_x000A_";
           case '\t' :
              if (canonical)
                 return "_x0009_";
           case ' ' :
              if (canonical)
                 return "_x0020_";
           case '_' :
              if (canonical)
                 return "_x005f_";
              // else, default print char
           default :
              return "" + c;
        }
     }
docs: Normalizes and print the given character.