Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
Hello All,
I am using Uri.UnescapeDataString() function, when i am passing the sttring then getting fallowing
error. There is an invalid sequence in the string.

I checked the string there is a character, which is creating the problem, charecter is copied from word document. character was ‘…’.
I think these single quote is creating the problem. Single quate is diffrent then other single quote('').

how can i resolve the issue?
Posted
Comments
Karthik_Mahalingam 21-Jan-14 0:37am    
can u post the string
amit_83 21-Jan-14 0:51am    
String was ‘…’
JoCodes 21-Jan-14 1:25am    
the whole string was only '...'? I just tried with the same but was not able to reproduce.

Try to replace copied single quotes with original single quotes and pass in to that method
C#
var  result = yourString.Replace("‘", "'");

Hope this helps
 
Share this answer
 
Comments
amit_83 21-Jan-14 1:39am    
Thanks to all, I got the solution i used HttpUtility.UrlDecode in please of UnescapeDataString(). It work.
Before you pass your sting to Uri.UnescapeDataString()funcation, handel that character or replace them with standard characters.
some thing like...
C#
..........
string strTest =  "‘testing string’";
strTest = strTest.Replace("’","'");
............


or you can also create funcation which will handel this type of special characters in your string like this...

C#
public string ReplaceCharacter(string str){
   // you can add as many character as you need to handel
   str= str.Replace("’","'").Replace("`", "'");
}
string strTest =  "‘testing string’";
strTest = ReplaceCharacter(strTest);
 
Share this answer
 
v4
Comments
amit_83 21-Jan-14 0:59am    
Thanks for reply, This is not a good solution. This type of problem may come with other characters as well. Do you have other suggestion?
Thanks to all,
I got the solution, i used HttpUtility.UrlDecode in place of UnescapeDataString().
And its work.!!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900