我正在使用此代码:
using System.Net;
function() {
using (WebClient Client = new WebClient())
{
Client.DownloadFile("http://translate.google.com/translate_tts?tl=en&q=hello", "a.mp3");
}
}
工作正常。请注意我正在下载的英语。主要问题出现在我想使用非拉丁字母的语言时,例如泰语:
using System.Net;
function() {
using (WebClient Client = new WebClient())
{
Client.DownloadFile("http://translate.google.com/translate_tts?tl=th&q=สวัสดี", "a.mp3");
}
}
但这给了我一个没有那个单词声音的非现实mp3。请问如何解决?
请注意本网站的主要结构:
...translate.google.com/translate_tts?tl=**en**&q=**hello**"
...translate.google.com/translate_tts?tl=**th**&q=**สวัสดี**"
答案 0 :(得分:1)
使用HttpUtility.UrlPathEncode("สวัสดี")
对Unicode字符进行编码。