0

我正在寻找一个免费的 Java翻译API,我发现 microsoft-translator-java-api,它很容易使用我喜欢它,但是当我从英语翻译阿拉伯语时,就像:

public static void main( String[] args ) throws Exception {       

    // Set the Client ID / Client Secret once per JVM. It is set statically and applies to all services
    Translate.setClientId("MY_CLIENT_ID_KEY");
    Translate.setClientSecret("MY_CLIENT_SECRET_KEY");

    // From English-> Arabic
    String translatedText = Translate.execute("When creating a text field component, it’s common to specify some initial text and/or a number of columns from which the field’s width is calculated.", Language.ENGLISH, Language.ARABIC);

    System.out.println(" English -> Arabic: " + translatedText);

}

我在控制台上显示为:

 English -> Arabic : ??? ????? ???? ??? ??? ?????? ?????? ??? ???? ??????? ?/?? ??? ?? ??????? ???? ?? ?????? ??? ???? ????? ?????.

我很困惑如何修复这个错误,以便我可以在控制台上获得一些有意义的完整字符,而不是上面的。

4

1 回答 1

1

您必须更改控制台的编码UTF-8才能正确显示阿拉伯字符。
如果您使用的是 eclipse,请执行以下步骤:

步骤1:

单击运行 --> 运行配置..

在此处输入图像描述

第2步:

单击通用选项卡 -> 选择其他 -> 将编码更改为 UTF-8

在此处输入图像描述

第 3 步:

单击应用,现在可以在控制台上打印阿拉伯文本。

于 2014-11-15T04:08:40.400 回答