Changeset 29794


Ignore:
Timestamp:
2015-03-19T14:07:11+13:00 (9 years ago)
Author:
kjdon
Message:

trying to get a proper unicode version of the filename. Need to convert to long windows filenames if on windows, decode any %XX url codes, need to change to composed form if on macs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/util.pm

    r29708 r29794  
    164164}
    165165
     166sub raw_filename_to_unicode
     167{
     168    my ($directory, $raw_file) = @_;
     169       
     170    my $unicode_filename = &util::get_dirsep_tail(&util::upgrade_if_dos_filename(&FileUtils::filenameConcatenate($directory, $raw_file), 1));
     171    $unicode_filename = &Encode::decode("utf8", $unicode_filename);
     172    #$unicode_filename = &Encode::decode(locale => $unicode_filename);
     173
     174    #Does the filenaem have url encoded chars in it?
     175        if (&unicode::is_url_encoded($unicode_filename)) {
     176            $unicode_filename = &unicode::url_decode($unicode_filename);
     177            }
     178    print STDERR "after url decoding: $unicode_filename\n";
     179    # Normalise the filename to canonical composition - on mac, filenames use decopmposed form for accented chars
     180    if ($ENV{'GSDLOS'} =~ m/^darwin$/i) {
     181       $unicode_filename = normalize('C', $unicode_filename); # Composed form 'C'
     182       }
     183    return $unicode_filename;
     184
     185}
    166186sub fd_exists {
    167187  warnings::warnif("deprecated", "util::fd_exists() is deprecated, using FileUtils::fileTest() instead");
Note: See TracChangeset for help on using the changeset viewer.