返回介绍

QHebrewCodec Class

发布于 2019-10-04 15:00:37 字数 3357 浏览 953 评论 0 收藏 0

The QHebrewCodec class provides conversion to and from visually ordered Hebrew. More...

#include <qrtlcodec.h>

Inherits QTextCodec.

List of all member functions.

Public Members

  • virtual const char * mimeName () const
  • virtual QCString fromUnicode ( constQString&uc, int&len_in_out ) const

Detailed Description

The QHebrewCodec class provides conversion to and from visually ordered Hebrew.

Hebrew as a semitic language is written from right to left. Because older computer systems couldn't handle reordering a string so that the first letter appears on the right, many older documents were encoded in visual order, so that the first letter of a line is the rightmost one in the string.

In contrast to this, Unicode defines characters to be in logical order (the order you would read the string). This codec tries to convert visually ordered Hebrew (8859-8) to Unicode. This might not always work perfectly, because reversing the bidi (bi-directional) algorithm that transforms from logical to visual order is non-trivial.

Transformation from Unicode to visual Hebrew (8859-8) is done using the bidi algorithm in Qt, and will produce correct results, so long as the codec is given the text one whole paragraph at a time. Places where newlines are supposed to start can be indicated by a newline character ('\n'). Please be aware, that these newline characters change the reordering behaviour of the algorithm, as the BiDi reordering only takes place within one line of text, whereas linebreaks are determined in visual order.

Visually ordered Hebrew is still used quite often in some places, mainly in email communication (as most email programs still don't understand logically ordered Hebrew) and on web pages. The use on web pages is strongly decreasing however, as there are now a few browsers that correctly support logically ordered Hebrew.

This codec has the name "iso8859-8". If you don't want any bidi reordering to happen during conversion, use the "iso8859-8-i" codec, which assumes logical order for the 8-bit string.

See also Internationalization with Qt.


Member Function Documentation

QCString QHebrewCodec::fromUnicode ( constQString&uc, int&len_in_out ) const [virtual]

Transforms the logically ordered QString, uc, into a visually ordered string in the 8859-8 encoding. Qt's bidi algorithm is used to perform this task. Note that newline characters affect the reordering, as reordering is done on a line by line basis.

The algorithm is designed to work on whole paragraphs of text, so processing a line at a time may produce incorrect results. This approach is taken because the reordering of the contents of a particular line in a paragraph may depend on the previous line in the same paragraph.

Some encodings (for example Japanese or utf8) are multibye (so one input character is mapped to two output characters). The len_in_out argument specifies the number of QChars that should be converted and is set to the number of characters returned.

Reimplemented from QTextCodec.

const char * QHebrewCodec::mimeName () const [virtual]

Returns the codec's mime name.

Reimplemented from QTextCodec.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文