src/main/java/org/jboss/util/file/Files.java
/**
    * See decodeFileName(String) above.
    *  
    * @param name the filename to decode
    * @param escape the escape character to use
    * @return the original name
    */


@param name the filename to decode
@param escape the escape character to use
@return the original name
@param name the filename to decode @param escape the escape character to use @return the original name
public static String decodeFileName(String name, char escape)
   {
      if (name == null)
      {
         return null;
      }
      StringBuffer sbuf = new StringBuffer(name.length());
      for (int i = 0; i < name.length(); i++)
      {
         char c = name.charAt(i);
         if (c == escape)
         {
            char h1 = name.charAt(++i);
            char h2 = name.charAt(++i);
            int d1 = (h1 >= 'a') ? (10 + h1 - 'a')
                  : ((h1 >= 'A') ? (10 + h1 - 'A') 
                                     :  (h1 - '0'));
            int d2 = (h2 >= 'a') ? (10 + h2 - 'a')
                  : ((h2 >= 'A') ? (10 + h2 - 'A')
                                      : (h2 - '0'));
            byte[] bytes = new byte[] { (byte)(d1 * 16 + d2) };
            try 
            {
               String s = new String(bytes, "UTF8");
               sbuf.append(s);
            }
            catch (UnsupportedEncodingException wonthappen)
            {
            }
         }
         else
         {
            sbuf.append(c);
         }
      }
      return sbuf.toString();
   }
public static String decodeFileName ( String name , char escape ) { if ( name == null ) { return null ; } StringBuffer sbuf = new StringBuffer ( name . length ( ) ) ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { char c = name . charAt ( i ) ; if ( c == escape ) { char h1 = name . charAt ( ++ i ) ; char h2 = name . charAt ( ++ i ) ; int d1 = ( h1 >= 'a' ) ? ( 10 + h1 - 'a' ) : ( ( h1 >= 'A' ) ? ( 10 + h1 - 'A' ) : ( h1 - '0' ) ) ; int d2 = ( h2 >= 'a' ) ? ( 10 + h2 - 'a' ) : ( ( h2 >= 'A' ) ? ( 10 + h2 - 'A' ) : ( h2 - '0' ) ) ; byte [ ] bytes = new byte [ ] { ( byte ) ( d1 * 16 + d2 ) } ; try { String s = new String ( bytes , "UTF8" ) ; sbuf . append ( s ) ; } catch ( UnsupportedEncodingException wonthappen ) { } } else { sbuf . append ( c ) ; } } return sbuf . toString ( ) ; }
See decodeFileName(String) above.
See decodeFileName ( String ) above .
// convert hex digits to integers // handling only the <esc>hh case here, as we don't know // if <esc>hh<esc>hh belong to the same character // (and we are lazy to change the encoding) - REVISIT // nada