Ignore:
Timestamp:
2008-08-07T13:52:36+12:00 (16 years ago)
Author:
ak19
Message:

URL encode and URL decode subroutines added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/unicode.pm

    r16553 r16672  
    544544}
    545545
    546 
    547546# Returns true (1) if the given string is utf8 and false (0) if it isn't.
    548547# Does not modify the string parameter.
     
    577576}
    578577
     578sub url_encode {
     579    my ($text) = @_;
     580    $text =~ s/([^A-Z0-9\.\-\_])/sprintf("%%%02X", ord($1))/iseg;
     581    # URL_encode spaces too?
     582    #$text =~ s/ /%20/sg;
     583    return $text;
     584}
     585
     586sub url_decode {
     587    my ($text) = @_;
     588
     589    $text =~ s/\%([A-F0-9]{2})/pack('C', hex($1))/ige;
     590    return $text;
     591}
     592
    579593sub substr
    580594{
Note: See TracChangeset for help on using the changeset viewer.