在C#中,将文本编码为URL? [英] In C#, encode text to URL?

查看:158
本文介绍了在C#中,将文本编码为URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://translate.google.com/translate_tts?tl=en&q= Hello + world! [ ^ ]



上面的链接有效,但是当有很多带有特殊字符的复杂文本时如果说链接不再起作用,如何将文本编码为C#中的URL以在C#中的此链接中说出?









string text =这是一个文本!,需要通过谷歌在线文字发言;



//在这里以URL格式编码文本



Mp3player.playFromURL(@http://translate.google.com/translate_tts?tl= en& amp; q =+ text;

http://translate.google.com/translate_tts?tl=en&q=Hello+world![^]

the link above works, but when there's lots of complex text with special chars to be spoken the link doesn't work anymore, how to encode text to a URL in C# to be spoken in this link in C#?




string text="This is a text!, needs to be spoken by Google Online Text To Speech";

//encode text in URL format here

Mp3player.playFromURL(@"http://translate.google.com/translate_tts?tl=en&q="+text);

推荐答案

C#/ ASP.Net有Server.URLEncode()



http://msdn.microsoft.com/en -us / library / ms525738%28v = vs.90%29.aspx [ ^ ]
C#/ASP.Net has Server.URLEncode()

http://msdn.microsoft.com/en-us/library/ms525738%28v=vs.90%29.aspx[^]


这篇关于在C#中,将文本编码为URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆