写阿拉伯语和英语之间的文本文件混合 [英] write text file mix between arabic and english

查看:1550
本文介绍了写阿拉伯语和英语之间的文本文件混合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用包含阿拉伯语和英语的文本文件句子写,但是这两种语言都有方向RTL和LTR的问题所以输出文本文件不保存单词的顺序,而某些单词在彼此之前出现这是错误的,当我从记事本或任何文本编辑器更改文本方向时修复了问题,有没有办法使用java修复此问题?

i'm trying to write in text file sentences that contains Arabic and English but the problem that both languages have direction RTL and LTR so the output text file don't save the order of the words and some words come before each other that is wrong, the problem fixed when i change the text direction from the notepad or any text editor, is there any way to fix this using java?

推荐答案

正如我在您对上一个问题的评论中所解释的那样,Unicode文本文件按逻辑顺序存储字符。 记录的算法有关如何处理双向文本,以及控制可插入到双向文本中的字符的方法。例如,当您在英语句子中间有阿拉伯语引号时,文本流可以向渲染器提供有关附加标点符号的提示。

As I explained in my comment on your previous question, Unicode text files store the characters in logical order. There is a documented algorithm for how to handle bidirectional text, and control characters you can insert into the text stream to give hints to the renderer about, for example, where to attach punctuation when you have an Arabic quotation in the middle of an English sentence.

但最终选择整个文本的顶级主导方向的问题是显示文本的组件而不是文本本身可以控制的内容 - 渲染器必须决定它是否是处理包含一些阿拉伯语的大部分英语段落,反之亦然。

But ultimately the choice of the top-level "predominant" direction of the text as a whole is a matter for the component that is displaying the text rather than something that the text itself can control - the renderer has to decide whether it's dealing with a mostly-English paragraph containing some bits of Arabic or vice-versa.

例如,假设我有一个包含以下逻辑字符序列的文件(在行中)使用bidi算法规范中的约定我使用小写字母表示从左到右的字符,例如英语和大写字母表示从右到左的字符,例如阿拉伯语:

For example, suppose I have a file containing the following logical sequence of characters (in line with the conventions in the bidi algorithm spec I use lowercase for left-to-right characters such as English and UPPERCASE for right-to-left characters such as Arabic):

abc def GHI! JKL mno? PQR

配置为将文本视为主要为LTR的查看器将其呈现为

A viewer configured to treat the text as predominantly LTR would render this as

abc def LKJ !IHG mno? RQP

而配置为将其视为主要RTL的查看器将呈现完全相同的文本 as

whereas a viewer configured to treat it as predominantly RTL would render exactly the same text as

                                      RQP ?mno LKJ !IHG abc def

(在没有控制字符的情况下,位于LTR和RTL段之间边界的标点符号将附加到与整个段落方向匹配的标点符号)

(in the absence of control characters to the contrary the punctuation that lies at the boundary between a LTR and RTL segment will attach to the one that matches the overall paragraph direction)

这篇关于写阿拉伯语和英语之间的文本文件混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆