One workaround is to Escape the special symbols using the System.Uri.EscapeDataString() method. Following is a code snippet, which adds a link with a special symbol and then escapes all symbols above the 128 in the ASCII table in all links in the RadDocument:
string webAddress = "https://lovdata.no/lov/2005-06-17-62/§14-5"; // Hyperlink with special symbol §
HyperlinkInfo info = new HyperlinkInfo()
{
NavigateUri = webAddress,
Target = HyperlinkTargets.Blank,
IsAnchor = false
};
this.radRichTextBox.InsertHyperlink(info, webAddress); // Add hyperlink with special symbol
IEnumerable<HyperlinkRangeStart> links = this.radRichTextBox.Document.EnumerateChildrenOfType<HyperlinkRangeStart>(); // Get all HyperlinkRangeStart elements for iteration
foreach (HyperlinkRangeStart link in links)
{
HyperlinkInfo hyperlinkInfo = link.HyperlinkInfo;
string originalUri = hyperlinkInfo.NavigateUri;
string modifiedUri = originalUri;
for (int i = 0; i < originalUri.Length; i++)
{
char character = originalUri[i];
if ((int)character > 127)
{
string escapedChar = Uri.EscapeDataString(webAddress[i].ToString()); // Escapes symbol
string escapedUri = originalUri.Replace(character.ToString(), escapedChar); // Replaces symbol
modifiedUri = escapedUri;
}
}
hyperlinkInfo.NavigateUri = modifiedUri; // Replaces modified URI in HyperlinkInfo element
Regards,
Svilen
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.