@ Nullable protected String getEncodedTextDescription ( int tagType ) { byte [ ] commentBytes = _directory . getByteArray ( tagType ) ; if ( commentBytes == null ) return null ; if ( commentBytes . length == 0 ) return "" ; final Map < String , String > encodingMap = new HashMap < String , String > ( ) ; encodingMap . put ( "ASCII" , System . getProperty ( "file.encoding" ) ) ; // Someone suggested "ISO-8859-1". encodingMap . put ( "UNICODE" , "UTF-16LE" ) ; encodingMap . put ( "JIS" , "Shift-JIS" ) ; // We assume this charset for now. Another suggestion is "JIS". try { if ( commentBytes . length >= 10 ) { String firstTenBytesString = new String ( commentBytes , 0 , 10 ) ; // try each encoding name for ( Map . Entry < String , String > pair : encodingMap . entrySet ( ) ) { String encodingName = pair . getKey ( ) ; String charset = pair . getValue ( ) ; if ( firstTenBytesString . startsWith ( encodingName ) ) { // skip any null or blank characters commonly present after the encoding name, up to a limit of 10 from the start for ( int j = encodingName . length ( ) ; j < 10 ; j ++ ) { byte b = commentBytes [ j ] ; if ( b != ' ' && b != ' ' ) return new String ( commentBytes , j , commentBytes . length - j , charset ) . trim ( ) ; } return new String ( commentBytes , 10 , commentBytes . length - 10 , charset ) . trim ( ) ; } } } // special handling fell through, return a plain string representation return new String ( commentBytes , System . getProperty ( "file.encoding" ) ) . trim ( ) ; } catch ( UnsupportedEncodingException ex ) { return null ; } }
EXIF UserComment GPSProcessingMethod and GPSAreaInformation