29 #include <unicode/utypes.h>
30 #include <unicode/ucnv.h>
31 #include <unicode/uchar.h>
32 #include <unicode/ustring.h>
33 #include <unicode/unorm2.h>
38 struct UTF8NFKDPrivate {
39 const UNormalizer2 *conv;
43 UErrorCode err = U_ZERO_ERROR;
44 p =
new struct UTF8NFKDPrivate;
45 p->conv = unorm2_getNFKDInstance(&err);
56 UErrorCode err = U_ZERO_ERROR;
57 UChar *source, *target;
59 if ((
unsigned long)key < 2)
62 int32_t len = 5 + text.
length() * 5;
63 source =
new UChar[len + 1];
67 u_strFromUTF8(source, len, &ulen, text.
c_str(), (int32_t)text.
size(), &err);
70 target =
new UChar[len + 1];
73 ulen = unorm2_normalize(
p->conv, source, ulen, target, len, &err);
76 u_strToUTF8 (text.
getRawData(), len, &len, target, ulen, &err);
#define SWORD_NAMESPACE_START
unsigned long length() const
const char * c_str() const
unsigned long size() const
struct UTF8NFKDPrivate * p
virtual char processText(SWBuf &text, const SWKey *key=0, const SWModule *module=0)
#define SWORD_NAMESPACE_END
void setSize(unsigned long len)