Changeset 29793 for main/trunk/gli
- Timestamp:
- 2015-03-19T13:53:24+13:00 (9 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer/metadata
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/metadata/FilenameEncoding.java
r23436 r29793 32 32 import java.util.*; 33 33 import org.greenstone.gatherer.collection.CollectionManager; 34 34 import org.greenstone.gatherer.DebugStream; 35 35 36 36 /** Static access class that contains many of the methods used to work with filename encodings. … … 347 347 348 348 String filename_ascii = filename_uri.toASCIIString(); 349 DebugStream.println("ascii = "+filename_ascii); 349 350 String filename_raw_bytes = URLDecoder.decode(filename_ascii,"ISO-8859-1"); 351 DebugStream.println("raw = "+filename_raw_bytes); 350 352 filename_url_encoded = iso_8859_1_filename_to_url_encoded(filename_raw_bytes); 353 351 354 } 352 355 catch (Exception e) { … … 355 358 filename_url_encoded = file.getAbsolutePath(); 356 359 } 360 DebugStream.println("returning "+filename_url_encoded); 357 361 return filename_url_encoded; 358 362 } … … 368 372 { 369 373 String urlEncoded = ""; 370 374 DebugStream.println("in iso 8859 to url encoded, "+raw_bytes_filename); 371 375 try { 372 376 // By this point we have a UTF-8 encoded string that captures … … 386 390 String unicode_filename = new String(raw_bytes,"UTF-8"); 387 391 392 //urlEncoded = URLEncoder.encode(unicode_filename, "UTF-8"); 388 393 for(int i = 0; i < unicode_filename.length(); i++) { 389 394 char charVal = unicode_filename.charAt(i); 390 if((int)charVal > 127) { 395 if ((int)charVal > 255) { 396 urlEncoded += String.format("&#x%02X;", (int)charVal); 397 //urlEncoded += String.format("\\u%04X", (int)charVal); 398 } 399 else if((int)charVal > 127) { 391 400 urlEncoded += String.format("%%%02X", (int)charVal); 401 //urlEncoded += Integer.toHexString((int)charVal); 392 402 } else { 393 403 urlEncoded += String.format("%c", (char)charVal); … … 399 409 throw(e); 400 410 } 401 411 DebugStream.println("returning "+urlEncoded); 402 412 return urlEncoded; 403 413 } -
main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java
r23433 r29793 45 45 static final private String FILESET_ELEMENT = "FileSet"; 46 46 static final private String METADATA_ELEMENT = "Metadata"; 47 47 static final private String[] nonEscapingElements = new String[]{FILENAME_ELEMENT}; 48 48 49 /** Special metadata field: the filename encoding is a unique sort of metadata in 49 50 * that it is not just information stored with a collection file, but also needs to … … 123 124 // If no appropriate FileSet element exists create a new one for this file 124 125 if (appropriate_fileset_element == null) { 125 DebugStream.println("Creating new FileSet element for file since none exists..." );126 DebugStream.println("Creating new FileSet element for file since none exists..."+file_path_regexp); 126 127 appropriate_fileset_element = loaded_file_document.createElement(FILESET_ELEMENT); 127 128 … … 605 606 // If we have a file loaded into memory and it has been modified, save it now 606 607 if (loaded_file != null && loaded_file_changed == true) { 607 XMLTools.writeXMLFile(loaded_file, loaded_file_document); 608 XMLTools.writeXMLFile(loaded_file, loaded_file_document, nonEscapingElements); 609 610 608 611 loaded_file_changed = false; 609 612 }
Note:
See TracChangeset
for help on using the changeset viewer.