ResponseSubmittedEventArgs.Response - strange characters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

I have followed the MSDN documentation to implement use of the
"Notification"-class to let the user enter data.

http://msdn2.microsoft.com/en-us/library/microsoft.windowsce.forms.notification(vs.80).aspx

Private Sub ctlNotification_ResponseSubmitted(ByVal sender As System.Object,
ByVal e As Microsoft.WindowsCE.Forms.ResponseSubmittedEventArgs) Handles
ctlNotification.ResponseSubmitted

When I interprete the e.Response some characters has been replaced by the
system, and that is really annoying.

E g the string "A B/C" becomes "A+B%2FC".
The space character has been replaced with a "+"
And the "/" character has been replaced with the string "%2FC".

How to prevent this distortion of the entered string?
Or is there a built in method for restoring the string?

Best regards
Benjamin,
Sweden
 
The return string you are providing is html encoded. you can perform a html
decode on the string to get the original string.

Rick D.
Contractor
 
Hi Rick!

Do you mean the "HttpUtility.HtmlDecode"-method?

Thanks for the suggestion, but the HttpUtility Class is not supported by the
".NET Compact Framework." (I am building a smart client using "Windows Mobile
5.0 Pocket PC SDK" in Visual Studio 2005.)

I am seeking an equivalent method that is supported...

Benjamin
 
Yes, give that a try and see if the results are what you expected.

Rick D.
Contractor
 
Sorry,
forgot that CF did not contain this class. I'll look some more, but my may
need to write a class that performs the html decoding for you. You can
search Google for decoding requirements.

Rick D.
Contractor.
 
Hi!

Ok, so everybody that uses HTML code in the Notification-class needs to
"HTML Decode" the return string with a user created function (as I have
understood from previous posts). But this must be a common task, though I do
not find any obvious match on google. Any hint?

Benjamin
 
It's a pretty simple and well-documented process on how HTML encoding works.
It's largely just a hex replacement. For example here's one from a project
I have (I wouldn't say it's complete or the best way to go, but it works and
gives you an idea how it works):

public static string HTMLDecode(string safeURL)
{
if (safeURL == null) return null;

string url = safeURL;
url = url.Replace('+', ' ');
url = url.Replace("%20", " ");
url = url.Replace("%21", "!");
url = url.Replace("%22", "\"");
url = url.Replace("%23", "#");
url = url.Replace("%24", "$");
url = url.Replace("%25", "%");
url = url.Replace("%26", "&");
url = url.Replace("%27", "'");
url = url.Replace("%28", "(");
url = url.Replace("%29", ")");
url = url.Replace("%2a", "*");
url = url.Replace("%2b", "+");
url = url.Replace("%2c", ",");
url = url.Replace("%2d", "-");
url = url.Replace("%2e", ".");
url = url.Replace("%2f", "/");
url = url.Replace("%2A", "*");
url = url.Replace("%2B", "+");
url = url.Replace("%2C", ",");
url = url.Replace("%2D", "-");
url = url.Replace("%2E", ".");
url = url.Replace("%2F", "/");
url = url.Replace("%3c", "<");
url = url.Replace("%3d", "=");
url = url.Replace("%3e", ">");
url = url.Replace("%3f", "?");
url = url.Replace("%3C", "<");
url = url.Replace("%3D", "=");
url = url.Replace("%3E", ">");
url = url.Replace("%3F", "?");
url = url.Replace("%40", "@");

return url;
}


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top