1

我正在使用这段代码:

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=**สวัสดี**"

4

1 回答 1

1

用于HttpUtility.UrlPathEncode("สวัสดี")对 Unicode 字符进行编码。

于 2014-06-22T15:39:00.200 回答