Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

utf8arshaping.cpp

00001 /******************************************************************************
00002 *
00003 * utf8arshaping - SWFilter decendant to perform Arabic shaping on
00004 *                   UTF-8 text
00005 */
00006 
00007 #ifdef _ICU_
00008 
00009 #include <stdlib.h>
00010 #include <string.h>
00011 
00012 #ifdef __GNUC__
00013 #include <unixstr.h>
00014 #endif
00015 
00016 #include <utf8arshaping.h>
00017 
00018 UTF8arShaping::UTF8arShaping() {
00019 
00020         conv = ucnv_open("UTF-8", &err);
00021 
00022 }
00023 
00024 UTF8arShaping::~UTF8arShaping() {
00025         ucnv_close(conv);
00026 }
00027 
00028 char UTF8arShaping::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
00029 {
00030         UChar *ustr, *ustr2;
00031 
00032         int32_t len = strlen(text);
00033         ustr = new UChar[len];
00034         ustr2 = new UChar[len];
00035 
00036         // Convert UTF-8 string to UTF-16 (UChars)
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         delete [] ustr2;
00044         delete [] ustr;
00045         return 0;
00046 }
00047 
00048 #endif

Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by doxygen1.2.15