Back to index

lightning-sunbird  0.9+nobinonly
nsUnicodeToX11Johab.cpp
Go to the documentation of this file.
00001 /*
00002  * @(#)CharToByteX11Johab.java  1.1 99/08/28
00003  *
00004  * ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is CharToByteX11Johab.java.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Deogtae Kim <dtkim@calab.kaist.ac.kr> (98/05/03)
00021  * Portions created by the Initial Developer are Copyright (C) 2001
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Deogtae Kim <dtkim@calab.kaist.ac.kr> (99/08/28)
00026  *   Jungshik Shin <jshin@pantheon.yale.edu>
00027  *   Pierre Phaneuf <pp@ludusdesign.com>
00028  *
00029  * Alternatively, the contents of this file may be used under the terms of
00030  * either of the GNU General Public License Version 2 or later (the "GPL"),
00031  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00032  * in which case the provisions of the GPL or the LGPL are applicable instead
00033  * of those above. If you wish to allow use of your version of this file only
00034  * under the terms of either the GPL or the LGPL, and not to allow others to
00035  * use your version of this file under the terms of the MPL, indicate your
00036  * decision by deleting the provisions above and replace them with the notice
00037  * and other provisions required by the GPL or the LGPL. If you do not delete
00038  * the provisions above, a recipient may use your version of this file under
00039  * the terms of any one of the MPL, the GPL or the LGPL.
00040  *
00041  * ***** END LICENSE BLOCK ***** */
00042 
00043 #include "nsUnicodeToX11Johab.h"
00044 #include "nsUCvKODll.h"
00045 
00046 
00047 typedef char byte;
00048 
00049 // XPCOM stuff
00050 NS_IMPL_ADDREF(nsUnicodeToX11Johab)
00051 NS_IMPL_RELEASE(nsUnicodeToX11Johab)
00052 nsresult nsUnicodeToX11Johab::QueryInterface(REFNSIID aIID,
00053                                           void** aInstancePtr)
00054 {
00055   if (NULL == aInstancePtr) {
00056     return NS_ERROR_NULL_POINTER;
00057   }
00058 
00059   *aInstancePtr = NULL;
00060 
00061   static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
00062 
00063   if (aIID.Equals(NS_GET_IID(nsIUnicodeEncoder))) {
00064     *aInstancePtr = (void*) ((nsIUnicodeEncoder*)this);
00065     NS_ADDREF_THIS();
00066     return NS_OK;
00067   }
00068   if (aIID.Equals(NS_GET_IID(nsICharRepresentable))) {
00069     *aInstancePtr = (void*) ((nsICharRepresentable*)this);
00070     NS_ADDREF_THIS();
00071     return NS_OK;
00072   }
00073   if (aIID.Equals(kISupportsIID)) {
00074     *aInstancePtr = (void*) ((nsISupports*)((nsIUnicodeEncoder*)this));
00075     NS_ADDREF_THIS();
00076     return NS_OK;
00077   }
00078 
00079   return NS_NOINTERFACE;
00080 }
00081 
00082 
00083 NS_IMETHODIMP nsUnicodeToX11Johab::SetOutputErrorBehavior(
00084       PRInt32 aBehavior,
00085       nsIUnicharEncoder * aEncoder, PRUnichar aChar)
00086 {
00087    return NS_ERROR_NOT_IMPLEMENTED;
00088 }
00089 
00090 //   1 /*
00091 //   2  * @(#)CharToByteX11Johab.java  1.0 98/05/03
00092 //   3  *
00093 //   4  * Purposes:
00094 //   5  *   1. Enable displaying all 11,172 Modern hangul syllables with Hanterm
00095 //   6  *      johab fonts on Unix
00096 //   7  *   2. Enable displaying some of Unicode 2.0 ancient hangul syllables
00097 //   8  *      with Hanterm johab fonts on Unix
00098 //   9  *   3. Enable displaying all of Unicode 2.0 ancient hangul syllables with
00099 //  10  *      possible future extended Hanterm johab fonts on Unix
00100 //  11  *
00101 //  12  * Installation Instructions:
00102 //  13  * 1. Install Hanterm Johab fonts and a proper font property file to Unix syste
00103 //  14 m.
00104 //  15  *    (Confer http://calab.kaist.ac.kr/~dtkim/java/ )
00105 //  16  * 2. Make a directory "jdk1.x.x/classes/"
00106 //  17  * 3. Compile this class into "jdk1.x.x/classes/"
00107 //  18  *
00108 //  19  * Author: Deogtae Kim <dtkim@calab.kaist.ac.kr>, 98/05/03
00109 //  20  *
00110 //  21  * Based on: Hanterm source code adapted by Jungshik Shin <jshin@pantheon.yale.
00111 //  22 edu>
00112 //  23  */
00113 //  24 
00114 //  25 import sun.io.CharToByteConverter;
00115 //  26 import sun.io.MalformedInputException;
00116 //  27 import sun.io.UnknownCharacterException;
00117 //  28 import sun.io.ConversionBufferFullException;
00118 //  29 
00119 //  30 public class CharToByteX11Johab extends CharToByteConverter
00120 //  31 {
00121 //  32     int state = START;
00122 //  33 
00123 //  34     public static final int START = 0;
00124 //  35     public static final int LEADING_CONSONANT = 1;
00125 //  36     public static final int VOWEL = 2;
00126 //  37 
00127 //  38     int l = 0x5f; // leading consonant
00128 //  39     int v = 0;    // vowel
00129 //  40     int t = 0;    // trailing consonant
00130 
00131 #define START 1
00132 #define LEADING_CONSONANT 1
00133 #define VOWEL 2
00134 
00135 // constructor and destroctor
00136 
00137 nsUnicodeToX11Johab::nsUnicodeToX11Johab()
00138 {
00139    Reset();
00140    state = START;
00141    l = 0x5f;
00142    v = 0;
00143    t = 0;
00144 
00145 }
00146 nsUnicodeToX11Johab::~nsUnicodeToX11Johab()
00147 {
00148 }
00149 
00150 //  41 
00151 //  42     /*
00152 //  43      * This method indicates the charset name for this font.
00153 //  44      */
00154 //  45     public String getCharacterEncoding()
00155 //  46     {
00156 //  47         return "X11Johab";
00157 //  48     }
00158 //  49 
00159 //  50     /*
00160 //  51      * This method indicates the range this font covers.
00161 //  52      */
00162 //  53     public boolean canConvert(char ch)
00163 //  54     {
00164 //  55         if ( 0xac00 <= ch && ch <= 0xd7a3      // Modern hangul syllables
00165 //  56              || 0x1100 <= ch && ch <= 0x1112   // modern leading consonants (19
00166 //  57 )
00167 //  58              || 0x1113 <= ch && ch <= 0x1159   // ancient leading consonants (7
00168 //  59 1)
00169 //  60                 && lconBase[ch-0x1100] != 0
00170 //  61              || ch == 0x115f                   // leading consonants filler
00171 //  62              || 0x1160 <= ch && ch <= 0x1175   // modern vowels (21)
00172 //  63              || 0x1176 <= ch && ch <= 0x11a2   // ancient vowels (45)
00173 //  64                 && vowBase[ch-0x1160] != 0
00174 //  65              || 0x11a8 <= ch && ch <= 0x11c2   // modern trailing consonants (2
00175 //  66 7)
00176 //  67              || 0x11c3 <= ch && ch <= 0x11f9   // ancient trailing consonants (
00177 //  68 55)
00178 //  69                 && tconBase[ch-0x11a7] != 0 )
00179 //  70             return true;
00180 //  71         return false;
00181 //  72     }
00182 
00183 #define canConvert(ch) \
00184  (((0xac00 <=(ch))&&((ch)<= 0xd7a3))    /* Modern hangul syllables         */\
00185    || ((0x1100 <=(ch))&&((ch)<= 0x1112)) /* modern leading consonants (19)  */\
00186    || ((0x1113 <=(ch))&&((ch)<= 0x1159) /* ancient leading consonants (71) */\
00187        && (lconBase[ch-0x1100] != 0))                                        */\
00188    || ((ch) == 0x115f)                 /* leading consonants filler       */\
00189    || ((0x1160 <=(ch))&&((ch)<= 0x1175))  /* modern vowels (21)              */\
00190    || ((0x1176 <=(ch))&&((ch)<= 0x11a2) /* ancient vowels (45)             */\
00191        && (vowBase[(ch)-0x1160] != 0  ))                                        */\
00192    || ((0x11a8 <=(ch))&&((ch)<= 0x11c2))/* modern trailing consonants (27) */\
00193    || ((0x11c3 <=(ch))&&((ch)<= 0x11f9) /* ancient trailing consonants (55)*/\
00194        && (tconBase[(ch)-0x11a7] != 0 )))
00195 
00196 //  73 
00197 //  74     /*
00198 //  75      * This method converts the unicode to this font index.
00199 //  76      * Note: ConversionBufferFullException is not handled
00200 //  77      *       since this class is only used for character display.
00201 //  78      */
00202 //  79     public int convert(char[] input, int inStart, int inEnd,
00203 //  80                        byte[] output, int outStart, int outEnd)
00204 //  81         throws MalformedInputException, UnknownCharacterException
00205 //  82     {
00206 NS_IMETHODIMP nsUnicodeToX11Johab::Convert(
00207       const PRUnichar * input, PRInt32 * aSrcLength,
00208       char * output, PRInt32 * aDestLength)
00209 {
00210 //  83         charOff = inStart;
00211 //  84         byteOff = outStart;
00212                 charOff = byteOff = 0;
00213 /*  85 */
00214 /*  86 */      for (; charOff < *aSrcLength; charOff++)
00215 /*  87 */      {
00216 /*  88 */          PRUnichar ch = input[charOff];
00217 /*  89 */          if (0xac00 <= ch && ch <= 0xd7a3)
00218 /*  90 */          {
00219 /*  91 */              if ( state != START )
00220 /*  92 */                  composeHangul(output);
00221 /*  93 */              ch -= 0xac00;
00222 /*  94 */              l = (ch / 588);        // 588 = 21*28
00223 /*  95 */              v = ( ch / 28 ) % 21  + 1;
00224 /*  96 */              t = ch % 28;
00225 /*  97 */              composeHangul(output);
00226 /*  98 */          } else if (0x1100 <= ch && ch <= 0x115f)
00227 /*  99 */          {  // leading consonants (19 + 71 + 1)
00228 /* 100 */              if ( state != START )
00229 /* 101 */                  composeHangul(output);
00230 /* 102 */              l = ch - 0x1100;
00231 /* 103 */              state = LEADING_CONSONANT;
00232 /* 104 */          } else if (1160 <= ch && ch <= 0x11a2)
00233 /* 105 */          {  // vowels (1 + 21 + 45)
00234 /* 106 */              v = ch - 0x1160;
00235 /* 107 */              state = VOWEL;
00236 /* 108 */          } else if (0x11a8 <= ch && ch <= 0x11f9)
00237 /* 109 */          {  // modern trailing consonants (27)
00238 /* 110 */              t = ch - 0x11a7;
00239 /* 111 */              composeHangul(output);
00240 // 112             } else
00241 // 113             {
00242 // 114                 throw new UnknownCharacterException();
00243 /* 115 */           }
00244 /* 116 */       }
00245 /* 117 */
00246 /* 118 */       if ( state != START )
00247 /* 119 */           composeHangul( output );
00248 /* 120 */
00249 // 121          return byteOff - outStart;
00250 // 122      }
00251                  *aDestLength = byteOff;
00252                  return NS_OK;
00253 }
00254 // 123 
00255 // 124     public int flush(byte output[], int i, int j)
00256 // 125         throws MalformedInputException
00257 // 126     {
00258 NS_IMETHODIMP nsUnicodeToX11Johab::Finish(
00259       char * output, PRInt32 * aDestLength)
00260 {
00261 /* 127 */      byteOff = 0;
00262 /* 128 */      PRInt32 len = 0;
00263 /* 129 */      if ( state != START )
00264 /* 130 */      {
00265 /* 131 */          composeHangul( output );
00266 /* 132 */          len = byteOff;
00267 /* 133 */      }
00268 /* 134 */      byteOff = charOff = 0;
00269 // 135         return len;
00270                 *aDestLength = len;
00271 // 136     }
00272 // 137 
00273    return NS_OK;
00274 }
00275 
00276 //================================================================
00277 NS_IMETHODIMP nsUnicodeToX11Johab::Reset()
00278 // 138     public void reset()
00279 /* 139 */  {
00280 /* 140 */      byteOff = charOff = 0;
00281 /* 141 */      state = START;
00282 /* 142 */      l = 0x5f;
00283 /* 143 */      v = t = 0;
00284                return NS_OK;
00285 /* 144 */  }
00286 //================================================================
00287 // 145 
00288 // 146     public int getMaxBytesPerChar()
00289 // 147     {
00290 // 148         return 6;
00291 // 149     }
00292 
00293 NS_IMETHODIMP nsUnicodeToX11Johab::GetMaxLength(
00294       const PRUnichar * aSrc, PRInt32 aSrcLength,
00295       PRInt32 * aDestLength)
00296 {
00297    *aDestLength = (aSrcLength + 1) *  6;
00298    return NS_OK;
00299 }
00300 //================================================================
00301 
00302 // 150 
00303 // 151     // The base font index for leading consonants
00304 // 152 
00305 // 153     static final short[] lconBase = {
00306 static const PRUint16 lconBase[] = {
00307 /* 154 */       // modern leading consonants (19)
00308 /* 155 */       1, 11, 21, 31, 41, 51,
00309 /* 156 */       61, 71, 81, 91, 101, 111,
00310 /* 157 */       121, 131, 141, 151, 161, 171,
00311 /* 158 */       181, 
00312 /* 159 */
00313 /* 160 */       // ancient leading consonants (71 + reserved 5 + filler 1)
00314 /* 161 */       0, 0, 0, 0, 0, 0,       // \u1113 ~ : 
00315 /* 162 */       0, 0, 0, 0, 0, 201,     // \u1119 ~ :
00316 /* 163 */       0, 221, 251, 0, 0, 0,   // \u111f ~ :
00317 /* 164 */       0, 0, 281, 0, 0, 0,     // \u1125 ~ :
00318 /* 165 */       191, 0, 211, 0, 231, 0, // \u112b ~ :
00319 /* 166 */       0, 241, 0, 0, 0, 291,   // \u1131 ~ :
00320 /* 167 */       0, 0, 0, 0, 0, 0,       // \u1137 ~ :
00321 /* 168 */       0, 0, 0, 261, 0, 0,     // \u113d ~ :
00322 /* 169 */       0, 0, 0, 0, 0, 0,       // \u1143 ~ :
00323 /* 170 */       0, 0, 0, 271, 0, 0,     // \u1149 ~ :
00324 /* 171 */       0, 0, 0, 0, 0, 0,       // \u114f ~ :
00325 /* 172 */       0, 0, 0, 0, 301,        // \u1155 ~ :
00326 /* 173 */       0, 0, 0, 0, 0,          // \u115a ~ : reserved
00327 /* 174 */       0,                      // \u115f   : leading consonant filler
00328 /* 175 */  };
00329 //================================================================
00330 // 176 
00331 // 177     // The base font index for vowels
00332 // 178 
00333 // 179     static final short[] vowBase = {
00334 static const PRUint16 vowBase[] = {
00335 /* 180 */      // modern vowels (filler + 21)
00336 /* 181 */      0,311,314,317,320,323,   // (Fill), A, AE, YA, YAE, EO
00337 /* 182 */      326,329,332,335,339,343, // E, YEO, YE, O, WA, WAE
00338 /* 183 */      347,351,355,358,361,364, // OI, YO, U, WEO, WE, WI
00339 /* 184 */      367,370,374,378,         // YU, EU, UI, I
00340 /* 185 */ 
00341 /* 186 */      // ancient vowels (45)
00342 /* 187 */      0, 0, 0, 0, 0, 0,        // \u1176 ~ : A-O, A-U, YA-O, YA-YO, EO-O, EO- U
00343 /* 189 */      0, 0, 0, 0, 0, 0,        // \u117c ~ : EO-EU, YEO-O, YEO-U, O-EO, O-E, O-YE
00344 /* 191 */      0, 0, 381, 384, 0, 0,    // \u1182 ~ : O-O, O-U, YO-YA, YO-YAE, YO-YEO,  YO-O
00345 /* 193 */      387, 0, 0, 0, 0, 0,      // \u1188 ~ : YO-I, U-A, U-AE, U-EO-EU, U-YE, U-U
00346 /* 195 */      0, 0, 0, 390, 393, 0,    // \u118e ~ : YU-A, YU-EO, YU-E, YU-YEO, YU-YE , YU-U
00347 /* 197 */      396, 0, 0, 0, 0, 0,      // \u1194 ~ : YU-I, EU-U, EU-EU, YI-U, I-A, I- YA
00348 /* 199 */      0, 0, 0, 0, 399, 0,      // \u119a ~ : I-O, I-U, I-EU, I-ARAEA, ARAEA,      ARAEA-EO
00349 /* 201 */      0, 402, 0                // \u11a0 ~ : ARAEA-U, ARAEA-I,SSANGARAEA 
00350 /* 202 */  };
00351 //================================================================
00352 // 203 
00353 // 204     // The base font index for trailing consonants
00354 // 205 
00355 // 206     static final short[] tconBase = {
00356 static const PRUint16 tconBase[] = {
00357 // 207         // modern trailing consonants (filler + 27)
00358 /* 208 */      0, 
00359 /* 209 */      405, 409, 413, 417, 421,
00360 /* 210 */      425, 429, 433, 437, 441,
00361 /* 211 */      445, 459, 453, 457, 461,
00362 /* 212 */      465, 469, 473, 477, 481,
00363 /* 213 */      485, 489, 493, 497, 501,
00364 /* 214 */      505, 509,
00365 // 215         
00366 // 216         // ancient trailing consonants (55)
00367 /* 217 */      0, 0, 0, 0, 0, 0,      // \u11c3 ~ :
00368 /* 218 */      0, 0, 0, 0, 0, 0,      // \u11c9 ~ :
00369 /* 219 */      0, 0, 0, 0, 0, 0,      // \u11cf ~ :
00370 /* 220 */      0, 0, 0, 0, 513, 517,  // \u11d5 ~ :
00371 /* 221 */      0, 0, 0, 0, 0, 0,      // \u11db ~ :
00372 /* 222 */      0, 0, 0, 0, 0, 0,      // \u11e1 ~ :
00373 /* 223 */      0, 0, 0, 0, 0, 0,      // \u11e7 ~ :
00374 /* 224 */      0, 0, 0, 525, 0, 0,    // \u11ed ~ :
00375 /* 225 */      0, 0, 0, 0, 0, 0,      // \u11f3 ~ :
00376 /* 226 */      521                    // \u11f9:
00377 /* 227 */  };
00378 //================================================================
00379 // 228 
00380 // 229     // The mapping from vowels to leading consonant type
00381 // 230     // in absence of trailing consonant
00382 // 231 
00383 // 232     static final short[] lconMap1 = {
00384 static const PRUint8 lconMap1[] = {
00385 /* 233 */      0,0,0,0,0,0,     // (Fill), A, AE, YA, YAE, EO
00386 /* 234 */      0,0,0,1,3,3,     // E, YEO, YE, O, WA, WAE
00387 /* 235 */      3,1,2,4,4,4,     // OI, YO, U, WEO, WE, WI
00388 /* 236 */      2,1,3,0,         // YU, EU, UI, I
00389 // 237 
00390 // 238         // ancient vowels (45)
00391 /* 239 */      3, 4, 3, 3, 3, 4,   // \u1176 ~ : A-O, A-U, YA-O, YA-YO, EO-O, EO-U
00392 /* 240 */      4, 3, 4, 3, 3, 3,   // \u117c ~ : EO-EU, YEO-O, YEO-U, O-EO, O-E, O-YE
00393 /* 241 */      1, 1, 3, 3, 3, 1,   // \u1182 ~ : O-O, O-U, YO-YA, YO-YAE, YO-YEO, YO-O
00394 /* 242 */      3, 4, 4, 4, 4, 2,   // \u1188 ~ : YO-I, U-A, U-AE, U-EO-EU, U-YE, U-U
00395 /* 243 */      3, 3, 3, 3, 3, 2,   // \u118e ~ : YU-A, YU-EO, YU-E, YU-YEO, YU-YE, YU-U
00396 /* 245 */      4, 2, 2, 4, 0, 0,   // \u1194 ~ : YU-I, EU-U, EU-EU, YI-U, I-A, I-YA
00397 /* 246 */      3, 4, 3, 0, 1, 3,   // \u119a ~ : I-O, I-U, I-EU, I-ARAEA, ARAEA, ARAEA-EO
00398 /* 248 */      2, 3, 1             // \u11a0 ~ : ARAEA-U, ARAEA-I, SSANGARAEA
00399 /* 249 */  };
00400 //================================================================
00401 // 250 
00402 // 251     // The mapping from vowels to leading consonant type
00403 // 252     // in presence of trailing consonant
00404 // 253 
00405 static const PRUint8 lconMap2[] = {
00406 // 254     static final short[] lconMap2 = {
00407 /* 255 */      5,5,5,5,5,5,     // (Fill), A, AE, YA, YAE, EO
00408 /* 256 */      5,5,5,6,8,8,     // E, YEO, YE, O, WA, WAE
00409 /* 257 */      8,6,7,9,9,9,     // OI, YO, U, WEO, WE, WI
00410 /* 258 */      7,6,8,5,         // YU, EU, UI, I
00411 // 259 
00412 // 260         // ancient vowels (45)
00413 /* 261 */      8, 9, 8, 8, 8, 9,   // \u1176 ~ : A-O, A-U, YA-O, YA-YO, EO-O, EO-U
00414 /* 262 */      9, 8, 9, 8, 8, 8,   // \u117c ~ : EO-EU, YEO-O, YEO-U, O-EO, O-E, O-YE
00415 /* 263 */      6, 6, 8, 8, 8, 6,   // \u1182 ~ : O-O, O-U, YO-YA, YO-YAE, YO-YEO, YO-O
00416 /* 264 */      8, 9, 9, 9, 9, 7,   // \u1188 ~ : YO-I, U-A, U-AE, U-EO-EU, U-YE, U-U
00417 /* 265 */      8, 8, 8, 8, 8, 7,   // \u118e ~ : YU-A, YU-EO, YU-E, YU-YEO, YU-YE, Y
00418 /* 267 */      9, 7, 7, 9, 5, 5,   // \u1194 ~ : YU-I, EU-U, EU-EU, YI-U, I-A, I-YA
00419 /* 268 */      8, 9, 8, 5, 6, 8,   // \u119a ~ : I-O, I-U, I-EU, I-ARAEA, ARAEA, ARAEA-EO
00420 /* 270 */      7, 8, 6             // \u11a0 ~ : ARAEA-U, ARAEA-I, SSANGARAEA
00421 /* 271 */  };
00422 //================================================================
00423 // 272 
00424 // 273     // vowel type ; 1 = o and its alikes, 0 = others            
00425 // 274     static final short[] vowType = {
00426 static const PRUint8 vowType[] = {
00427 /* 275 */      0,0,0,0,0,0,
00428 /* 276 */      0,0,0,1,1,1,
00429 /* 277 */      1,1,0,0,0,0,
00430 /* 278 */      0,1,1,0,
00431 // 279 
00432 // 280         // ancient vowels (45)
00433 /* 281 */      1, 0, 1, 1, 1, 0,   // \u1176 ~ : A-O, A-U, YA-O, YA-YO, EO-O, EO-U
00434 /* 282 */      0, 1, 0, 1, 1, 1,   // \u117c ~ : EO-EU, YEO-O, YEO-U, O-EO, O-E, O-YE
00435 /* 283 */      1, 1, 0, 0, 0, 0,   // \u1182 ~ : O-O, O-U, YO-YA, YO-YAE, YO-YEO, YO-O
00436 /* 284 */      0, 0, 0, 0, 0, 0,   // \u1188 ~ : YO-I, U-A, U-AE, U-EO-EU, U-YE, U-U
00437 /* 285 */      0, 0, 0, 0, 0, 0,   // \u118e ~ : YU-A, YU-EO, YU-E, YU-YEO, YU-YE, YU-U
00438 /* 287 */      0, 0, 0, 0, 0, 0,   // \u1194 ~ : YU-I, EU-U, EU-EU, YI-U, I-A, I-YA
00439 /* 288 */      0, 0, 0, 0, 0, 0,   // \u119a ~ : I-O, I-U, I-EU, I-ARAEA, ARAEA, ARAEA-EO
00440 /* 290 */      0, 0, 0             // \u11a0 ~ : ARAEA-U, ARAEA-I, SSANGARAEA
00441 /* 291 */  };
00442 //================================================================
00443 // 292 
00444 // 293     // The mapping from trailing consonants to vowel type
00445 // 294 
00446 // 295     static final int[] tconType = {
00447 static const PRUint8 tconType[] = {
00448 /* 296 */      0, 1, 1, 1, 2, 1,
00449 /* 297 */      1, 1, 1, 1, 1, 1,
00450 /* 298 */      1, 1, 1, 1, 1, 1,
00451 /* 299 */      1, 1, 1, 1, 1, 1,
00452 /* 300 */      1, 1, 1, 1,
00453 // 301 
00454 // 302         // ancient trailing consonants (55)
00455 /* 303 */      1, 1, 1, 1, 1, 1,  // \u11c3 ~ :
00456 /* 304 */      1, 1, 1, 1, 1, 1,  // \u11c9 ~ :
00457 /* 305 */      1, 1, 1, 1, 1, 1,  // \u11cf ~ :
00458 /* 306 */      1, 1, 1, 1, 1, 1,  // \u11d5 ~ :
00459 /* 307 */      1, 1, 1, 1, 1, 1,  // \u11db ~ :
00460 /* 308 */      1, 1, 1, 1, 1, 1,  // \u11e1 ~ :
00461 /* 309 */      1, 1, 1, 1, 1, 1,  // \u11e7 ~ :
00462 /* 310 */      1, 1, 1, 1, 1, 1,  // \u11ed ~ :
00463 /* 311 */      1, 1, 1, 1, 1, 1,  // \u11f3 ~ :
00464 /* 312 */      1                  // \u11f9:
00465 /* 313 */  };
00466 //================================================================
00467 // 314 
00468 // 315     // The mapping from vowels to trailing consonant type
00469 // 316 
00470 // 317     static final int[] tconMap = {
00471 static const PRUint8 tconMap[] = {
00472 /* 318 */      0, 0, 2, 0, 2, 1,  // (Fill), A, AE, YA, YAE, EO
00473 /* 319 */      2, 1, 2, 3, 0, 0,  // E, YEO, YE, O, WA, WAE
00474 /* 320 */      0, 3, 3, 1, 1, 1,  // OI, YO, U, WEO, WE, WI
00475 /* 321 */      3, 3, 0, 1,        // YU, EU, UI, I
00476 // 322 
00477 // 323         // ancient vowels (45)
00478 /* 324 */      3, 3, 3, 3, 3, 3,   // \u1176 ~ : A-O, A-U, YA-O, YA-YO, EO-O, EO-U
00479 /* 325 */      3, 3, 3, 1, 0, 0,   // \u117c ~ : EO-EU, YEO-O, YEO-U, O-EO, O-E, O-YE
00480 /* 326 */      3, 3, 3, 1, 0, 3,   // \u1182 ~ : O-O, O-U, YO-YA, YO-YAE, YO-YEO, YO-O
00481 /* 327 */      0, 0, 0, 0, 0, 3,   // \u1188 ~ : YO-I, U-A, U-AE, U-EO-EU, U-YE, U-U
00482 /* 328 */      0, 1, 1, 1, 1, 3,   // \u118e ~ : YU-A, YU-EO, YU-E, YU-YEO, YU-YE, YU- U
00483 /* 330 */      1, 3, 3, 3, 2, 2,   // \u1194 ~ : YU-I, EU-U, EU-EU, YI-U, I-A, I-YA
00484 /* 331 */      3, 3, 3, 1, 3, 0,   // \u119a ~ : I-O, I-U, I-EU, I-ARAEA, ARAEA, ARAEA -EO
00485 /* 333 */      3, 2, 3             // \u11a0 ~ : ARAEA-U, ARAEA-I, SSANGARAEA
00486 /* 334 */  };
00487 //================================================================
00488 // 335 
00489 // 336     void composeHangul(byte[] output)
00490 void nsUnicodeToX11Johab::composeHangul(char* output)
00491 /* 337 */  {
00492 // 338         int ind;
00493                PRUint16 ind;
00494 /* 339  */ 
00495 /* 340 */      if ( lconBase[l] != 0 )
00496 /* 341 */      {   // non-filler and supported by Hanterm Johab fonts
00497 /* 342 */          ind = lconBase[l] + ( t > 0 ? lconMap2[v] : lconMap1[v] );
00498 /* 343 */          output[byteOff++] = (byte) (ind / 256);
00499 /* 344 */          output[byteOff++] = (byte) (ind % 256);
00500 /* 345 */      }
00501 /* 346  */
00502 /* 347 */      if ( vowBase[v] != 0 )
00503 /* 348 */      {   // non-filler and supported by Hanterm Johab fonts
00504 /* 349 */          ind = vowBase[v];
00505 /* 350 */          if ( vowType[v] == 1)
00506 /* 351 */          {   //'o' and alikes 
00507 /* 352 */              // GIYEOK and KIEUK got special treatment
00508 /* 353 */              ind += ( (l == 0 || l == 15) ? 0 : 1)
00509 /* 354 */                     + (t > 0 ?  2 : 0 );
00510 /* 355 */          }
00511 /* 356 */          else
00512 /* 357 */          { 
00513 /* 358 */              ind += tconType[t];
00514 /* 359 */          }
00515 /* 360  */
00516 /* 361 */          output[byteOff++] = (byte) (ind / 256);
00517 /* 362 */          output[byteOff++] = (byte) (ind % 256);
00518 /* 363 */      }
00519 /* 364 */
00520 /* 365 */      if ( tconBase[t] != 0 )  
00521 /* 366 */      {   // non-filler and supported by Hanterm Johab fonts
00522 /* 367 */          ind = tconBase[t] + tconMap[v];
00523 /* 368 */          output[byteOff++] = (byte) (ind / 256);
00524 /* 369 */          output[byteOff++] = (byte) (ind % 256);
00525 /* 370 */      } else  if (vowBase[v] == 0) 
00526 /* 371 */      {   // give one syllable display width since current display width is 0.
00527 /* 372 */          output[byteOff++] = (byte) 0;
00528 /* 373 */          output[byteOff++] = (byte) 0;
00529 /* 374 */      }
00530 /* 375 */
00531 /* 376 */      state = START;
00532 /* 377 */      l = 0x5f;
00533 /* 378 */      v = t = 0;
00534 /* 379  */  }
00535 // 380   }
00536 // 381 
00537 
00538 NS_IMETHODIMP nsUnicodeToX11Johab::FillInfo(PRUint32* aInfo)
00539 {
00540    // ac00-d7a3
00541    PRUint32 b = 0xac00 >> 5;
00542    PRUint32 e = 0xd7a3 >> 5;
00543    aInfo[ e ] |= (0xFFFFFFFFL >> (31 - ((0xd7a3) & 0x1f)));
00544    for( ; b < e ; b++)
00545       aInfo[b] |= 0xFFFFFFFFL;
00546 
00547    PRUnichar i;
00548 
00549    // 1100-1112
00550    for(i=0x1100;i<=0x1112;i++)
00551       SET_REPRESENTABLE(aInfo, i);
00552    // 1113-1159
00553    for(i=0x1113;i<=0x1159;i++)
00554       if(lconBase[i-0x1100]!=0)
00555          SET_REPRESENTABLE(aInfo, i);
00556    // 115f
00557    SET_REPRESENTABLE(aInfo, 0x115f);
00558    // 1160-1175
00559    for(i=0x1160;i<=0x1175;i++)
00560       SET_REPRESENTABLE(aInfo, i);
00561    // 1176-11a2
00562    for(i=0x1176;i<=0x11a2;i++)
00563       if(vowBase[i-0x1160]!=0)
00564          SET_REPRESENTABLE(aInfo, i);
00565    // 11a8-11c2
00566    for(i=0x11a8;i<=0x11c2;i++)
00567       SET_REPRESENTABLE(aInfo, i);
00568    // 11c3-11f9
00569    for(i=0x11c3;i<=0x11f9;i++)
00570       if(tconBase[i-0x11a7]!=0)
00571          SET_REPRESENTABLE(aInfo, i);
00572    return NS_OK;
00573 }