问题
Moving a question from the old MSDN forum here as it appears to be still open.
https://social.msdn.microsoft.com/Forums/en-US/ce8c4eae-ad14-4835-8537-fc3870538bbe/translator-api-notranslate-trimming-leading-space?forum=microsofttranslator
Is this a known bug, or intentional for any reason?
Are there any workarounds for this issue so that the API does not strip white spaces?
More examples:
回答1:
Translator trims leading and trailing space, and compresses any other white space to a single space. This is by design. Translator needs to move the words around freely to form the newly composed sentence, and wouldn't know what to do with the extra white space. A workaround would be to trim in your code before translation, and then restore the trimmed off pieces afterwards, depending on the context.
来源:https://stackoverflow.com/questions/46273868/microsoft-translator-api-notranslate-trimming-leading-space