Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsHankakuToZenkaku.cpp File Reference
#include "nsITextTransform.h"
#include "pratom.h"
#include "nsUUDll.h"
#include "nsTextTransformFactory.h"

Go to the source code of this file.

Classes

class  nsHankakuToZenkaku

Defines

#define NEED_TO_CHECK_NIGORI(u)   (((0xff76<=(u))&&((u)<=0xff84))||((0xff8a<=(u))&&((u)<=0xff8e)))
#define NEED_TO_CHECK_MARU(u)   ((0xff8a<=(u))&&((u)<=0xff8e))
#define IS_HANKAKU(u)   (0xff60==((u) & 0xffe0)) || (0xff80==((u)&0xffe0))
#define IS_NIGORI(u)   (0xff9e == (u))
#define IS_MARU(u)   (0xff9f == (u))
#define NIGORI_MODIFIER   1
#define MARU_MODIFIER   2

Functions

void HankakuToZenkaku (const PRUnichar *aSrc, PRInt32 aLen, PRUnichar *aDest, PRInt32 aDestLen, PRInt32 *oLen)
nsresult NS_NewHankakuToZenkaku (nsISupports **oResult)

Variables

static const PRUnichar gBasicMapping [0x40]

Define Documentation

#define IS_HANKAKU (   u)    (0xff60==((u) & 0xffe0)) || (0xff80==((u)&0xffe0))

Definition at line 72 of file nsHankakuToZenkaku.cpp.

#define IS_MARU (   u)    (0xff9f == (u))

Definition at line 74 of file nsHankakuToZenkaku.cpp.

#define IS_NIGORI (   u)    (0xff9e == (u))

Definition at line 73 of file nsHankakuToZenkaku.cpp.

Definition at line 76 of file nsHankakuToZenkaku.cpp.

#define NEED_TO_CHECK_MARU (   u)    ((0xff8a<=(u))&&((u)<=0xff8e))

Definition at line 69 of file nsHankakuToZenkaku.cpp.

#define NEED_TO_CHECK_NIGORI (   u)    (((0xff76<=(u))&&((u)<=0xff84))||((0xff8a<=(u))&&((u)<=0xff8e)))

Definition at line 66 of file nsHankakuToZenkaku.cpp.

Definition at line 75 of file nsHankakuToZenkaku.cpp.


Function Documentation

void HankakuToZenkaku ( const PRUnichar aSrc,
PRInt32  aLen,
PRUnichar aDest,
PRInt32  aDestLen,
PRInt32 oLen 
)

Definition at line 83 of file nsHankakuToZenkaku.cpp.

{
    // XXX aDestLen is never checked, assumed to be as long as aLen
    NS_ASSERTION(aDestLen >= aLen, "aDest must be as long as aSrc");

    PRInt32 i,j;
    if ( aLen == 0) {
      *oLen = 0;
      return;
    }
    // loop from the first to the last char except the last one.
    for(i = j = 0; i < (aLen-1); i++,j++,aSrc++, aDest++)
    {
       if(IS_HANKAKU(*aSrc)) {
         // if it is in hankaku - do basic mapping first
         *aDest = gBasicMapping[(*aSrc) - 0xff60];
         
         // if is some char could be modifier, and the next char
         // is a modifier, modify it and eat one byte

         if(IS_NIGORI(*(aSrc+1)) && NEED_TO_CHECK_NIGORI(*aSrc))
         {
            *aDest += NIGORI_MODIFIER;
            i++; aSrc++;
         }
         else if(IS_MARU(*(aSrc+1)) && NEED_TO_CHECK_MARU(*aSrc)) 
         {
            *aDest += MARU_MODIFIER;
            i++; aSrc++;
         }
       }
       else 
       {
         // not in hankaku block, just copy 
         *aDest = *aSrc;
       }
    }

    // handle the last character
    if(IS_HANKAKU(*aSrc)) 
         *aDest = gBasicMapping[(*aSrc) - 0xff60];
    else
         *aDest = *aSrc;

    *oLen = j+1;
}

Here is the caller graph for this function:

nsresult NS_NewHankakuToZenkaku ( nsISupports **  oResult)

Definition at line 181 of file nsHankakuToZenkaku.cpp.

Here is the call graph for this function:


Variable Documentation

const PRUnichar gBasicMapping[0x40] [static]
Initial value:
{

0xff60,0x3002,0x300c,0x300d,0x3001,0x30fb,0x30f2,0x30a1,        

0x30a3,0x30a5,0x30a7,0x30a9,0x30e3,0x30e5,0x30e7,0x30c3,        

0x30fc,0x30a2,0x30a4,0x30a6,0x30a8,0x30aa,0x30ab,0x30ad,        

0x30af,0x30b1,0x30b3,0x30b5,0x30b7,0x30b9,0x30bb,0x30bd,        

0x30bf,0x30c1,0x30c4,0x30c6,0x30c8,0x30ca,0x30cb,0x30cc,        

0x30cd,0x30ce,0x30cf,0x30d2,0x30d5,0x30d8,0x30db,0x30de,        

0x30df,0x30e0,0x30e1,0x30e2,0x30e4,0x30e6,0x30e8,0x30e9,        

0x30ea,0x30eb,0x30ec,0x30ed,0x30ef,0x30f3,0x309b,0x309c
}

Definition at line 45 of file nsHankakuToZenkaku.cpp.