blob: 93254de22f9613fd6c75adf899dd1ee88ce8662e (
plain) (
tree)
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>utf8arshaping.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>utf8arshaping.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment">*</font>
00003 <font class="comment">* utf8arshaping - SWFilter decendant to perform Arabic shaping on</font>
00004 <font class="comment">* UTF-8 text</font>
00005 <font class="comment">*/</font>
00006
00007 <font class="preprocessor">#ifdef _ICU_</font>
00008 <font class="preprocessor"></font>
00009 <font class="preprocessor">#include <stdlib.h></font>
00010 <font class="preprocessor">#include <string.h></font>
00011
00012 <font class="preprocessor">#ifdef __GNUC__</font>
00013 <font class="preprocessor"></font><font class="preprocessor">#include <unixstr.h></font>
00014 <font class="preprocessor">#endif</font>
00015 <font class="preprocessor"></font>
00016 <font class="preprocessor">#include <utf8arshaping.h></font>
00017
00018 UTF8arShaping::UTF8arShaping() {
00019
00020 conv = ucnv_open(<font class="stringliteral">"UTF-8"</font>, &err);
00021
00022 }
00023
00024 UTF8arShaping::~UTF8arShaping() {
00025 ucnv_close(conv);
00026 }
00027
00028 <font class="keywordtype">char</font> UTF8arShaping::ProcessText(<font class="keywordtype">char</font> *text, <font class="keywordtype">int</font> maxlen, <font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *key, <font class="keyword">const</font> <a class="code" href="class_s_w_module.html">SWModule</a> *module)
00029 {
00030 UChar *ustr, *ustr2;
00031
00032 int32_t len = strlen(text);
00033 ustr = <font class="keyword">new</font> UChar[len];
00034 ustr2 = <font class="keyword">new</font> UChar[len];
00035
00036 <font class="comment">// Convert UTF-8 string to UTF-16 (UChars)</font>
00037 len = ucnv_toUChars(conv, ustr, len, text, -1, &err);
00038
00039 len = u_shapeArabic(ustr, len, ustr2, len, U_SHAPE_LETTERS_SHAPE | U_SHAPE_DIGITS_EN2AN, &err);
00040
00041 ucnv_fromUChars(conv, text, maxlen, ustr2, len, &err);
00042
00043 <font class="keyword">delete</font> [] ustr2;
00044 <font class="keyword">delete</font> [] ustr;
00045 <font class="keywordflow">return</font> 0;
00046 }
00047
00048 <font class="preprocessor">#endif</font>
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>
|