All pastes #977196 Raw Edit

Something

public text v1 · immutable
·published 2008-04-08 18:07 UTC
rendered paste body
use warnings;
use SOAP::Lite;
use LWP::Simple;

my $soap = SOAP::Lite->service('http://apniurdu.com/SOAP/Urdu2.wsdl');

my $data = SOAP::Data->value ( 'Urdu is a great language' )-> type( 'string' );
my $dict = $soap -> GetWords ('');
my $text = $soap -> Translate ( $data );
my $urdu = $soap -> GetMapping ( $text );
my $utf8 = $soap -> GetUnicode ( $urdu );
$utf8 = &encode ($utf8);
print $utf8;
my $url = 'http://127.0.0.1:13003/cgi-bin/sendsms?username=test&password=test&from=UrduSMS&coding=2&charset=utf-8&to=00923008636664&text='. $utf8 ;
my $html = getprint ($url); # ok shoot to kannel to send sms



# Encode a string into urlencoded format
sub encode {
    local($instring) = @_;

    # Replace all Non-Numerics with HEX Sequence
    $instring =~s/[\x00-\x1F\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\xFF]/&hexCodeFromChar($&)/eg;

    # Replace all spaces with Plus Character
    $instring =~ s/ /+/g;

    return($instring);
}

# Decode a string from urlencoded format
sub decode {
    local($instring) = @_;

    # Replace all PLUS characters with Spaces
    $instring =~ tr/+/ /;

    # Replace Hex Codes with real characters
    $instring =~ s/%(..)/pack("C",hex($1))/eg;

    return($instring);
}

# Function used by both
sub hexCodeFromChar {
    my ($char) = @_;
    my $asc = ord($char);
    return(sprintf("%c%02X", 37, $asc));
}