Xamarin Forms: Pasted test contains + symbol inste

2019-08-29 05:09发布

Last year I asked a question about copy the entry value in xamarin forms.

When I test it now the white spaces in the text are filled by a + symbol. Also when pasting the emojis it is not working properly.

enter image description here

I am using Xamarin.Plugins.Clipboard NuGet package for copy the text to the clipboard. When copy text to clipboard I am using the following code:

 CrossClipboard.Current.SetText(message);

When long press in the device it shows the paste option. I am using that option for pasting the copied text.

Please suggest a solution for avoiding the + symbol? Also for emoji copy paste.

Thanks in advance.

1条回答
Bombasti
2楼-- · 2019-08-29 05:44

Problem should need to WebUtility.UrlDecode(String) the text :

Converts a string that has been encoded for transmission in a URL into a decoded string.

If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL encoding converts characters that are not allowed in a URL into equivalent hexadecimal escape sequences. The UrlEncode method creates a URL-encoded string.

URL decoding replaces hexadecimal escape sequences with corresponding ASCII character equivalents. For example, when embedded in a block of URL-encoded text, the escape sequences %3c and %3e are decoded into the characters < and >.

Sample as follow:

using System.Net;    

Console.WriteLine("Encode:" + WebUtility.UrlEncode("                                                                    
查看更多
登录 后发表回答