What he means is that you need to urlencode the message. This converts
control and other characters into hex representations of the same and
changes spaces into pluses (+).
So the string:
$msg = "Hello,\nI am working";
urlencoded becomes:
$msg = "Hello%2C%0AI+am+working";
The comma was changed to %2C, the newline to %0A and all the space into +'s.
I'm not a java programmer but I'm sure there is a function or at least
examples of how to do this. I use the following in Perl to accomplish
this:
# 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));
}
--
Kevin Reed - TNET Services, Inc.
For Mesa, AZ Weather http://www.TNETWeather.com
>
> can you please elaborate a little with an example. I am having much
> difficulty.
> thanks
> ________________________________
>> Date: Thu, 3 Apr 2008 16:54:15 -0300
>> From: [EMAIL PROTECTED]
>> To: [email protected]
>> Subject: Re: Response from Kannel
>>
>> urlencode the text, it will do the trick.
>>
>> On Thu, Apr 3, 2008 at 2:09 PM, Logic 1902 <[EMAIL PROTECTED]>
>> wrote:
>> Dear all, please tell me how can I add a new line in strings of
>> responses sent by kannel.
>>
>> forexamle, I want this message;
>>
>> Hello, I am working
>>
>> to look like this,
>>
>> Hello,
>> I am working
>>
>> I am using Java and as far as java language is concerned; new line
>> character is '\n' - but it does not work while i try with responses in
>> Kannel.
>>
>> Please suggest.
>>
>> regards,