在AJAX API中使用TranslateArray时出错 - 无法处理制表符或回车符 [英] Error with TranslateArray in AJAX API - can't handle tabs or carriage returns
问题描述
我正在翻译字符串时遇到问题。 首先,我正在使用AJAX API,因为我无法让非拉丁字符在HTTP API中正常工作。 无论如何,如果我的字符串包含制表符或CR-LF,我收到来自MS Translator
的错误,它似乎来自C#
I have an issue when I'm translating a string. First off, I'm using the AJAX API because I could not get non-Latin characters to work properly in the HTTP API. Anyway, if my strings contain tab or CR-LF, I get an error back from MS Translator which appears to come from C#
这是URL
http://api.microsofttranslator.com/v2/Ajax.svc/TranslateArray?appId=54431025E9B0356FBAAB7BC4F4DCA108258F7152&oncomplete=myf&from=fr&to=ja&options= {" ContentType":"文本/ HTML"}&安培;文本= ["%0D%0A +马++ R%C3%A9ponse + EST + traduite + EN +%3Cspan +类%3D%5C%22notranslate%5C%22%3EJava +为+ dummies%3C%2Fspan%3E。","Ceci + est + une + r%C3%A9ponse + pour + mon + avocat","Tout + pour + rien"]
http://api.microsofttranslator.com/v2/Ajax.svc/TranslateArray?appId=54431025E9B0356FBAAB7BC4F4DCA108258F7152&oncomplete=myf&from=fr&to=ja&options={"ContentType":"text/html"}&texts=["%0D%0A+Ma++r%C3%A9ponse+est+traduite+en+%3Cspan+class%3D%5C%22notranslate%5C%22%3EJava+for+dummies%3C%2Fspan%3E.","Ceci+est+une+r%C3%A9ponse+pour+mon+avocat","Tout+pour+rien"]
以下是响应
Here is the response
"反序列化System.String []类型的对象时出错。遇到无效字符'\ u000d'。"
"There was an error deserializing the object of type System.String[]. Encountered invalid character '\u000d'."
是否有解决方法?
-Hugh Ferguson
-Hugh Ferguson
推荐答案
您是否尝试将所有CRLF替换为其他字符,例如:((( 发送前)翻译文本并在获得翻译后将其替换回来?
Have you tried replacing all CRLF's with some other character like for eg: (((( before sending the texts for translation and replace them back after getting the translation?
这篇关于在AJAX API中使用TranslateArray时出错 - 无法处理制表符或回车符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!