0

Have a webpage that is opened from another system with parameters that can contain extended ascii characters:

http://<host>/submitpage.cshtml?pname=SomeName

The cshtml webpage reads the parameters as usual with:

var pname = Request["pname"];

and shows it on the page with @pname

Works fine for all browsers except IE (even IE11) when pname=Günther or another name with foreign characters; ü, ø and so on.

Example:
http://<host>/submitpage.cshtml?pname=Günther
results in G�nther

The webpage is using <meta charset="UTF-8" />

Any solution? I have no control over the submitting system, som the url cannot be encoded before submit.

  • Have you tried this? [Display encoded html with razor](http://stackoverflow.com/questions/5029264/display-encoded-html-with-razor) – emerson.marini Jun 16 '15 at 16:14
  • Or this? [How Decode HTML in MVC with RAZOR](http://stackoverflow.com/questions/11305787/how-decode-html-in-mvc-with-razor) – emerson.marini Jun 16 '15 at 16:15

1 Answers1

0

So between RFC3986 and RFC2234, we have the following relevant rules for URIs

pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"

sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
                / "*" / "+" / "," / ";" / "="

HEXDIG        =  DIGIT / "A" / "B" / "C" / "D" / "E" / "F"

pct-encoded   = "%" HEXDIG HEXDIG

query         = *( pchar / "/" / "?" )

unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"

ALPHA         =  %x41-5A / %x61-7A   ; A-Z / a-z

DIGIT         =  %x30-39 ; 0-9

so any implementation that accepts the unencoded letter ü is non-standards compliant and any user agent issuing requests with such characters is also non-compliant. It sounds like you know that this is the case.

IMO, it's a dangerous game making your own system more permissive to patch over the faults of "out of your control" systems. Are you sure the issuer of this request can't fix their code?

spender
  • 117,338
  • 33
  • 229
  • 351