Reputation: 395
I am trying to build some xml files with c#, the following is where i do get a problem :
StringBuilder tmp = new StringBuilder ();
tmp.Append ("<link>");
tmp.Append ("<url>").Append (link).Append ("</url>");
tmp.Append ("<hash>").Append ((link).Content.StringValue.ToUpper ()).Append ("</hash>");
tmp.Append ("</link>");
when the link
doesn't have some special characters like "é" it works fine, but for a link like "fr.wikipedia.org/wiki/Été" i get this error :
Exception occured while inserting entry: XML parsing: line 1, character 218, illegal xml character
Thanks
Upvotes: 0
Views: 100
Reputation: 2709
Accented characters aren't legal in URIs: tools.ietf.org/html/rfc3986#section-2
You should use System.Uri.EscapeUriString:
EscapeUriString((link).Content.StringValue.ToUpper())
Upvotes: 1