Reputation: 117
my messages normally comes like this in SMSgateway(gateway forwarded the message to our application),
sett pØll 1 2 3 4 5 6 7 8 121011 ( this message is correct )
But some cases this message comes like,
sett p&oslas;ll 1 2 3 4 5 6 7 8 121011 (this message incorrect,Ø comes with &oslas;)
this message comes as a string,when message comes &oslas; i need to replace it to Ø. sometimes it comes with another name, like gordØn(gord&oslas;n) It always stat with & sign & endsup with ; sign.
Here i tries to do it,but my knowledge is not enough to complete this..
protected void Page_Load(object sender, EventArgs e)
{
try
{
string mobileNo = Request.QueryString["msisdn"];
int dest = int.Parse(Request.QueryString["shortcode"].ToString());
string messageIn = Request.QueryString["msg"];
string operatorNew = Request.QueryString["operator"];
string []reparr = messageIn.Split(' ');//split it & then check contains
reparr[1].Contains = '&';
reparr[1].Contains = ';';
// In here i need to check that character & replace it to originalone.
Label1.Text = "ok";
WriteToFile(mobileNo, dest, messageIn, operatorNew,true,"","");
Upvotes: 0
Views: 367
Reputation: 2070
I am not aware about web namespace utilities but you may use below code (if position of & and ; is always going to be in beginning of message and these characters will not appear inside message text):
String s = @"sett p&oslas;ll 1 2 3 4 5 6 7 8 121011";
Int32 startIndex = s.IndexOf("&");
String s1 = s.Replace(s.Substring(startIndex, s.IndexOf(";") - startIndex + 1), "Ø");
Upvotes: 0
Reputation: 6615
you can use HttpServerUtility.UrlDecode to decode the url see http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.urldecode.aspx
Upvotes: 0
Reputation: 179677
Those look like HTML entities. You can try to decode them using HttpUtility.HtmlDecode
:
string messageIn = HttpUtility.HtmlDecode(Request.QueryString["msg"]);
Upvotes: 2