first check in

git-svn-id: svn://10.0.0.236/trunk@20792 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ftang%netscape.com 1999-02-16 18:13:35 +00:00
parent fe0412f001
commit 719c61207f
7 changed files with 1614 additions and 0 deletions

View File

@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIBreakState_h__
#define nsIBreakState_h__
#include "nsISupports.h"
#include "nscore.h"
// {EE874261-C0BF-11d2-B3AF-00805F8A6670}
#define NS_IBREAKSTATE_IID \
{ 0xee874261, 0xc0bf, 0x11d2, \
{ 0xb3, 0xaf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } };
class nsIBreakState : public nsISupports
{
public:
NS_IMETHOD Set (PRUint32 aPos, PRBool aDone) = 0;
NS_IMETHOD GetText (const PRUnichar** oText) = 0;
NS_IMETHOD Length (PRUint32* oLen) = 0;
NS_IMETHOD IsDone (PRBool *oDone) = 0;
NS_IMETHOD Current (PRUint32* oPos) = 0;
NS_IMETHOD SetPrivate (PRUint32 aPriv) = 0;
NS_IMETHOD GetPrivate (PRUint32* oPriv) = 0;
};
#define IMPL_NS_IBREAKSTATE(name) \
class name : public nsIBreakState { \
NS_DECL_ISUPPORTS \
name (const PRUnichar *aText, PRUint32 aLen) { \
NS_INIT_REFCNT(); \
mText = aText; mLen = aLen; \
mPos = 0; mPriv = 0; mDone = PR_FALSE; \
} ; \
~name () { } ; \
\
public: \
NS_IMETHOD Set (PRUint32 aPos, PRBool aDone) \
{ mPos = aPos; mDone = aDone; return NS_OK; }; \
\
NS_IMETHOD GetText (const PRUnichar** oText) \
{ *oText = mText; return NS_OK; }; \
\
NS_IMETHOD Length (PRUint32* oLen) \
{ *oLen = mLen; return NS_OK; }; \
\
NS_IMETHOD IsDone (PRBool *oDone) \
{ *oDone = mDone; return NS_OK; }; \
\
NS_IMETHOD Current (PRUint32* oPos) \
{ *oPos = mPos; return NS_OK; }; \
\
NS_IMETHOD SetPrivate (PRUint32 aPriv) \
{ mPriv = aPriv; return NS_OK; }; \
\
NS_IMETHOD GetPrivate (PRUint32* oPriv) \
{ *oPriv = mPriv ; return NS_OK; }; \
\
PRUint32 Current() { return mPos;}; \
\
PRUint32 IsDone() { return mDone;}; \
\
protected: \
PRUint32 mPos; \
PRBool mDone; \
PRUint32 mPriv; \
const PRUnichar*mText; \
PRUint32 mLen; \
}; \
NS_DEFINE_IID(kIBreakStateIID, NS_IBREAKSTATE_IID); \
NS_IMPL_ISUPPORTS( name , kIBreakStateIID);
#endif /* nsIBreakState_h__ */

View File

@ -0,0 +1,161 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
DO NOT EDIT THIS DOCUMENT !!! THIS DOCUMENT IS GENERATED BY
mozilla/intl/lwbrk/tools/anzx4501.pl
*/
static PRUint32 gLBClass00[32] = {
0x88888888, // U+0000 - U+0007
0x88888888, // U+0008 - U+000F
0x88888888, // U+0010 - U+0017
0x88888888, // U+0018 - U+001F
0x88438815, // U+0020 - U+0027
0x81515810, // U+0028 - U+002F
0x66666666, // U+0030 - U+0037
0x15551166, // U+0038 - U+003F
0x88888888, // U+0040 - U+0047
0x88888888, // U+0048 - U+004F
0x88888888, // U+0050 - U+0057
0x88180888, // U+0058 - U+005F
0x88888888, // U+0060 - U+0067
0x88888888, // U+0068 - U+006F
0x88888888, // U+0070 - U+0077
0x88180888, // U+0078 - U+007F
0x88888888, // U+0080 - U+0087
0x88888888, // U+0088 - U+008F
0x88888888, // U+0090 - U+0097
0x88888888, // U+0098 - U+009F
0x58383488, // U+00A0 - U+00A7
0x85888858, // U+00A8 - U+00AF
0x85888854, // U+00B0 - U+00B7
0x88888888, // U+00B8 - U+00BF
0x88888888, // U+00C0 - U+00C7
0x88888888, // U+00C8 - U+00CF
0x58888888, // U+00D0 - U+00D7
0x88888888, // U+00D8 - U+00DF
0x88888888, // U+00E0 - U+00E7
0x88888888, // U+00E8 - U+00EF
0x58888888, // U+00F0 - U+00F7
0x88888888, // U+00F8 - U+00FF
};
static PRUint32 gLBClass20[32] = {
0x88888888, // U+2000 - U+2007
0x88888888, // U+2008 - U+200F
0x88828888, // U+2010 - U+2017
0x01100110, // U+2018 - U+201F
0x82228888, // U+2020 - U+2027
0x88888888, // U+2028 - U+202F
0x88884444, // U+2030 - U+2037
0x88815888, // U+2038 - U+203F
0x88818888, // U+2040 - U+2047
0x88888888, // U+2048 - U+204F
0x88888888, // U+2050 - U+2057
0x88888888, // U+2058 - U+205F
0x88888888, // U+2060 - U+2067
0x88888888, // U+2068 - U+206F
0x88888888, // U+2070 - U+2077
0x88888888, // U+2078 - U+207F
0x88888888, // U+2080 - U+2087
0x88888888, // U+2088 - U+208F
0x88888888, // U+2090 - U+2097
0x88888888, // U+2098 - U+209F
0x88888888, // U+20A0 - U+20A7
0x88888888, // U+20A8 - U+20AF
0x88888888, // U+20B0 - U+20B7
0x88888888, // U+20B8 - U+20BF
0x88888888, // U+20C0 - U+20C7
0x88888888, // U+20C8 - U+20CF
0x88888888, // U+20D0 - U+20D7
0x88888888, // U+20D8 - U+20DF
0x88888888, // U+20E0 - U+20E7
0x88888888, // U+20E8 - U+20EF
0x88888888, // U+20F0 - U+20F7
0x88888888, // U+20F8 - U+20FF
};
static PRUint32 gLBClass21[32] = {
0x88888888, // U+2100 - U+2107
0x88888888, // U+2108 - U+210F
0x83888888, // U+2110 - U+2117
0x88888888, // U+2118 - U+211F
0x87888888, // U+2120 - U+2127
0x88888888, // U+2128 - U+212F
0x88888888, // U+2130 - U+2137
0x88888888, // U+2138 - U+213F
0x88888888, // U+2140 - U+2147
0x88888888, // U+2148 - U+214F
0x88888888, // U+2150 - U+2157
0x88888888, // U+2158 - U+215F
0x55555555, // U+2160 - U+2167
0x55555555, // U+2168 - U+216F
0x55555555, // U+2170 - U+2177
0x55555555, // U+2178 - U+217F
0x88888888, // U+2180 - U+2187
0x88888888, // U+2188 - U+218F
0x88888888, // U+2190 - U+2197
0x88888888, // U+2198 - U+219F
0x88888888, // U+21A0 - U+21A7
0x88888888, // U+21A8 - U+21AF
0x88888888, // U+21B0 - U+21B7
0x88888888, // U+21B8 - U+21BF
0x88888888, // U+21C0 - U+21C7
0x88888888, // U+21C8 - U+21CF
0x88888888, // U+21D0 - U+21D7
0x88888888, // U+21D8 - U+21DF
0x88888888, // U+21E0 - U+21E7
0x88888888, // U+21E8 - U+21EF
0x88888888, // U+21F0 - U+21F7
0x88888888, // U+21F8 - U+21FF
};
static PRUint32 gLBClass30[32] = {
0x55555115, // U+3000 - U+3007
0x10101010, // U+3008 - U+300F
0x10105510, // U+3010 - U+3017
0x11011010, // U+3018 - U+301F
0x55555555, // U+3020 - U+3027
0x55555555, // U+3028 - U+302F
0x55555555, // U+3030 - U+3037
0x55555555, // U+3038 - U+303F
0x15151515, // U+3040 - U+3047
0x55555515, // U+3048 - U+304F
0x55555555, // U+3050 - U+3057
0x55555555, // U+3058 - U+305F
0x55551555, // U+3060 - U+3067
0x55555555, // U+3068 - U+306F
0x55555555, // U+3070 - U+3077
0x55555555, // U+3078 - U+307F
0x15151555, // U+3080 - U+3087
0x51555555, // U+3088 - U+308F
0x55555555, // U+3090 - U+3097
0x51155555, // U+3098 - U+309F
0x15151515, // U+30A0 - U+30A7
0x55555515, // U+30A8 - U+30AF
0x55555555, // U+30B0 - U+30B7
0x55555555, // U+30B8 - U+30BF
0x55551555, // U+30C0 - U+30C7
0x55555555, // U+30C8 - U+30CF
0x55555555, // U+30D0 - U+30D7
0x55555555, // U+30D8 - U+30DF
0x15151555, // U+30E0 - U+30E7
0x51555555, // U+30E8 - U+30EF
0x51155555, // U+30F0 - U+30F7
0x51111555, // U+30F8 - U+30FF
};

View File

@ -0,0 +1,186 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <iostream.h>
#include "nsRepository.h"
#include "nsISupports.h"
#include "nsIServiceManager.h"
#include "nsILineBreakerFactory.h"
#include "nsILineBreaker.h"
#include "nsIBreakState.h"
#include "nsLWBrkCIID.h"
IMPL_NS_IBREAKSTATE( nsBreakState )
NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID);
NS_DEFINE_IID(kILineBreakerFactory, NS_ILINEBREAKERFACTORY_IID);
static char teng1[] =
// 1 2 3 4 5 6 7
//01234567890123456789012345678901234567890123456789012345678901234567890123456789
"This is a test to test(reasonable) line break. This 0.01123 = 45 x 48.";
static PRUint32 exp1[] = {
4,5,7,8,9,10,14,15,17,18,22,34,35,39,40,41,42,43,49,50,54,55,62,63,64,65,
67,68,69
};
// 1 2 3 4 5 6 7
//01234567890123456789012345678901234567890123456789012345678901234567890123456789
static char teng2[] =
"()((reasonab(l)e) line break. .01123=45x48.";
static PRUint32 exp2[] = {
2,12,15,17,18,22,23,24,30,31,37,38,40,41
};
// 1 2 3 4 5 6 7
//01234567890123456789012345678901234567890123456789012345678901234567890123456789
static char teng3[] =
"It's a test to test(ronae ) line break....";
static PRUint32 exp3[] = {
4, 5, 6,7,11,12,14,15,25,26,27,28,32,33
};
static char ruler1[] =
" 1 2 3 4 5 6 7 ";
static char ruler2[] =
"0123456789012345678901234567890123456789012345678901234567890123456789012";
void TestLineBreaker()
{
cout << "==================================\n";
cout << "Finish nsILineBreakerFactory Test \n";
cout << "==================================\n";
nsILineBreakerFactory *t = NULL;
nsresult res;
res = nsServiceManager::GetService(kLWBrkCID,
kILineBreakerFactory,
(nsISupports**) &t);
cout << "Test 1 - GetService():\n";
if(NS_FAILED(res) || ( t == NULL ) ) {
cout << "\t1st GetService failed\n";
} else {
res = nsServiceManager::ReleaseService(kLWBrkCID, t);
}
res = nsServiceManager::GetService(kLWBrkCID,
kILineBreakerFactory,
(nsISupports**) &t);
if(NS_FAILED(res) || ( t == NULL ) ) {
cout << "\t2nd GetService failed\n";
} else {
cout << "Test 3 - GetLineBreaker():\n";
nsILineBreaker *lb;
nsAutoString lb_arg("");
res = t->GetBreaker(lb_arg, &lb);
if(NS_FAILED(res) || (lb == NULL)) {
cout << "GetBreaker(nsILineBreaker*) failed\n";
} else {
cout << "Test 4 - {First,Next}ForwardBreak():\n";
PRUint32 expect = sizeof(exp1)/sizeof(char);
nsAutoString eng1(teng1);
nsBreakState bk(eng1.GetUnicode(), eng1.Length());
PRUint32 i,j;
PRUint32 res[256];
for(i = 0, lb->FirstForwardBreak(&bk);
(! bk.IsDone()) && (i < 256);
lb->NextForwardBreak(&bk), i++)
{
res [i] = bk.Current();
}
if (i != expect)
{
cout << "WARNING!!! return size wrong, expect " << expect <<
" bet got " << i << "\n";
}
cout << "string = \n" << teng1 << "\n";
cout << ruler1 << "\n";
cout << ruler2 << "\n";
for(j=0;j<i;j++)
{
cout << res[j] << ",";
}
for(j=0;j<i;j++)
{
if(j < expect)
{
if (res[j] != exp1[j])
{
cout << "[" << j << "] expect " << exp1[j] << " but got " <<
res[j] << "\n";
}
} else {
cout << "[" << j << "] additional " <<
res[j] << "\n";
}
}
NS_IF_RELEASE(lb);
}
res = nsServiceManager::ReleaseService(kLWBrkCID, t);
}
cout << "==================================\n";
cout << "Finish nsILineBreakerFactory Test \n";
cout << "==================================\n";
}
#ifdef XP_PC
#define LWBRK_DLL "lwbrk.dll"
#else
#ifdef XP_MAC
#define LWBRK_DLL "LWBRK_DLL"
#else
#endif
#define LWBRK_DLL "liblwbrk.so"
#endif
extern "C" void NS_SetupRegistry()
{
nsRepository::RegisterFactory(kLWBrkCID, LWBRK_DLL, PR_FALSE, PR_FALSE);
}
int main(int argc, char** argv) {
NS_SetupRegistry();
// --------------------------------------------
TestLineBreaker();
// --------------------------------------------
cout << "Finish All The Test Cases\n";
nsresult res = NS_OK;
res = nsRepository::FreeLibraries();
if(NS_FAILED(res))
cout << "nsRepository failed\n";
else
cout << "nsRepository FreeLibraries Done\n";
return 0;
}

View File

@ -0,0 +1,62 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ..\..\..
IGNORE_MANIFEST=1
MAKE_OBJ_TYPE = EXE
PROG1 = .\$(OBJDIR)\TestLineBreak.exe
PROGRAMS = $(PROG1)
LCFLAGS=-DUSE_NSREG
REQUIRES=libreg
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\lwbrk -I$(PUBLIC)\raptor
LLIBS= \
$(DIST)\lib\raptorbase.lib \
$(DIST)\lib\xpcom32.lib \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib
include <$(DEPTH)\config\rules.mak>
install:: $(PROGRAMS)
-for %p in ($(PROGRAMS)) do $(MAKE_INSTALL) %p $(DIST)\bin
clobber::
-for %p in ($(PROGRAMS)) do $(RM) %p $(DIST)\bin\%p
# Move this into config/obj.inc when it's allowed
.cpp{.\$(OBJDIR)\}.exe:
$(CC) @<<$(CFGFILE)
$(CFLAGS)
$(LCFLAGS)
$(LINCS)
$(LINCS_1)
$(INCS)
$(LLIBS)
$(OS_LIBS)
-Fd$(PBDFILE)
-Fe.\$(OBJDIR)\
-Fo.\$(OBJDIR)\
$(CURDIR)$(*B).cpp
<<KEEP
$(PROG1): $(OBJDIR) TestLineBreak.cpp

View File

@ -0,0 +1,716 @@
<HTML>
<HEAD>
<TITLE>
Analysis of JIS x4501 to Unicode General Category Mapping
</TITLE>
</HEAD>
<BODY>
<H1>
Analysis of JIS x4501 to Unicode General Category Mapping
</H1>
<TABLE BORDER=3>
<TR BGCOLOR=blue><TH><TH>
<TD BGCOLOR=red>C</TD>
<TD BGCOLOR=red>L</TD>
<TD BGCOLOR=red>M</TD>
<TD BGCOLOR=red>N</TD>
<TD BGCOLOR=red>P</TD>
<TD BGCOLOR=red>S</TD>
<TD BGCOLOR=red>Z</TD>
<TD BGCOLOR=white>Total</TD>
<TD BGCOLOR=yellow>Cc</TD>
<TD BGCOLOR=yellow>Cf</TD>
<TD BGCOLOR=yellow>Co</TD>
<TD BGCOLOR=yellow>Cs</TD>
<TD BGCOLOR=yellow>Ll</TD>
<TD BGCOLOR=yellow>Lm</TD>
<TD BGCOLOR=yellow>Lo</TD>
<TD BGCOLOR=yellow>Lt</TD>
<TD BGCOLOR=yellow>Lu</TD>
<TD BGCOLOR=yellow>Mc</TD>
<TD BGCOLOR=yellow>Me</TD>
<TD BGCOLOR=yellow>Mn</TD>
<TD BGCOLOR=yellow>Nd</TD>
<TD BGCOLOR=yellow>Nl</TD>
<TD BGCOLOR=yellow>No</TD>
<TD BGCOLOR=yellow>Pc</TD>
<TD BGCOLOR=yellow>Pd</TD>
<TD BGCOLOR=yellow>Pe</TD>
<TD BGCOLOR=yellow>Pf</TD>
<TD BGCOLOR=yellow>Pi</TD>
<TD BGCOLOR=yellow>Po</TD>
<TD BGCOLOR=yellow>Ps</TD>
<TD BGCOLOR=yellow>Sc</TD>
<TD BGCOLOR=yellow>Sk</TD>
<TD BGCOLOR=yellow>Sm</TD>
<TD BGCOLOR=yellow>So</TD>
<TD BGCOLOR=yellow>Zl</TD>
<TD BGCOLOR=yellow>Zp</TD>
<TD BGCOLOR=yellow>Zs</TD>
</TR>
<TR><TH>00_1<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>17</TD>
<TD></TD>
<TD></TD>
<TD BGCOLOR=white>17</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>4</TD>
<TD></TD>
<TD>13</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>01_[a]<TH>
<TD></TD>
<TD>27</TD>
<TD></TD>
<TD></TD>
<TD>29</TD>
<TD>1</TD>
<TD></TD>
<TD BGCOLOR=white>57</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>5</TD>
<TD>22</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>1</TD>
<TD>1</TD>
<TD>14</TD>
<TD>2</TD>
<TD></TD>
<TD>9</TD>
<TD>2</TD>
<TD></TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>02_7<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>4</TD>
<TD></TD>
<TD></TD>
<TD BGCOLOR=white>4</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>3</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>03_8<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>4</TD>
<TD></TD>
<TD BGCOLOR=white>4</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>3</TD>
<TD></TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>04_9<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>5</TD>
<TD>2</TD>
<TD></TD>
<TD BGCOLOR=white>7</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>5</TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>05_[b]<TH>
<TD></TD>
<TD>154</TD>
<TD></TD>
<TD>53</TD>
<TD>3</TD>
<TD>316</TD>
<TD>2</TD>
<TD BGCOLOR=white>528</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>154</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>33</TD>
<TD>20</TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>2</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>7</TD>
<TD>309</TD>
<TD></TD>
<TD></TD>
<TD>2</TD>
</TR>
<TR><TH>06_15<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>10</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD BGCOLOR=white>10</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>10</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>07_16<TH>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD BGCOLOR=white>1</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>08_18<TH>
<TD>9</TD>
<TD>661</TD>
<TD>4</TD>
<TD>130</TD>
<TD>51</TD>
<TD>929</TD>
<TD>14</TD>
<TD BGCOLOR=white>1798</TD>
<TD></TD>
<TD>9</TD>
<TD></TD>
<TD></TD>
<TD>370</TD>
<TD>1</TD>
<TD>5</TD>
<TD></TD>
<TD>285</TD>
<TD></TD>
<TD></TD>
<TD>4</TD>
<TD></TD>
<TD>3</TD>
<TD>127</TD>
<TD>3</TD>
<TD>6</TD>
<TD>3</TD>
<TD>2</TD>
<TD>2</TD>
<TD>32</TD>
<TD>3</TD>
<TD>12</TD>
<TD>8</TD>
<TD>258</TD>
<TD>651</TD>
<TD>1</TD>
<TD>1</TD>
<TD>12</TD>
</TR>
<TR><TH>09_nbsp<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD BGCOLOR=white>0</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>X<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD BGCOLOR=white>0</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
<TABLE BORDER=3>
<TR BGCOLOR=blue><TH><TH>
<TD BGCOLOR=red>00_1</TD>
<TD BGCOLOR=red>01_[a]</TD>
<TD BGCOLOR=red>02_7</TD>
<TD BGCOLOR=red>03_8</TD>
<TD BGCOLOR=red>04_9</TD>
<TD BGCOLOR=red>05_[b]</TD>
<TD BGCOLOR=red>06_15</TD>
<TD BGCOLOR=red>07_16</TD>
<TD BGCOLOR=red>08_18</TD>
<TD BGCOLOR=red>09_nbsp</TD>
<TD BGCOLOR=red>X</TD>
</TR>
<TR><TH>00<TH>
<TD>3</TD>
<TD>9</TD>
<TD></TD>
<TD>3</TD>
<TD>3</TD>
<TD>13</TD>
<TD>10</TD>
<TD></TD>
<TD>149</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>01<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>128</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>02<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>89</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>03<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>76</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>04<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>226</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>20<TH>
<TD>4</TD>
<TD>6</TD>
<TD>4</TD>
<TD></TD>
<TD>4</TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
<TD>90</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>21<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD>32</TD>
<TD></TD>
<TD>1</TD>
<TD>162</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>22<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>242</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>23<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>1</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>24<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>139</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>25<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>230</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>26<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>106</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>27<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>160</TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>30<TH>
<TD>10</TD>
<TD>42</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>161</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>32<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>132</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>33<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>188</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR><TH>4E<TH>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>256</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>

View File

@ -0,0 +1,375 @@
#!/usr/bin/perl
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
#
######################################################################
#
# Initial global variable
#
######################################################################
%utot = ();
$ui=0;
$li=0;
######################################################################
#
# Open the unicode database file
#
######################################################################
open ( UNICODATA , "< ../../unicharutil/tools/UnicodeData-Latest.txt")
|| die "cannot find UnicodeData-Latest.txt";
######################################################################
#
# Open the JIS x4501 Class file
#
######################################################################
open ( CLASS , "< jisx4501class.txt")
|| die "cannot find jisx4501class.txt";
######################################################################
#
# Open the JIS x4501 Class simplified mapping
#
######################################################################
open ( SIMP , "< jisx4501simp.txt")
|| die "cannot find jisx4501simp.txt";
######################################################################
#
# Open the output file
#
######################################################################
open ( OUT , "> anzx4501.html")
|| die "cannot open output anzx4501.html file";
######################################################################
#
# Open the output file
#
######################################################################
open ( HEADER , "> ../src/jisx4501class.h")
|| die "cannot open output ../src/jisx4501class.h file";
######################################################################
#
# Generate license and header
#
######################################################################
$hthmlheader = <<END_OF_HTML;
<HTML>
<HEAD>
<TITLE>
Analysis of JIS x4501 to Unicode General Category Mapping
</TITLE>
</HEAD>
<BODY>
<H1>
Analysis of JIS x4501 to Unicode General Category Mapping
</H1>
END_OF_HTML
print OUT $hthmlheader;
######################################################################
#
# Generate license and header
#
######################################################################
$npl = <<END_OF_NPL;
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
DO NOT EDIT THIS DOCUMENT !!! THIS DOCUMENT IS GENERATED BY
mozilla/intl/lwbrk/tools/anzx4501.pl
*/
END_OF_NPL
print HEADER $npl;
%occ = ();
%gcat = ();
%dcat = ();
%simp = ();
%gcount = ();
%dcount = ();
%sccount = ();
%rangecount = ();
######################################################################
#
# Process the file line by line
#
######################################################################
while(<UNICODATA>) {
chop;
######################################################################
#
# Get value from fields
#
######################################################################
@f = split(/;/ , $_);
$c = $f[0]; # The unicode value
$g = $f[2];
$d = substr($g, 0, 1);
$gcat{$c} = $g;
$dcat{$c} = $d;
$gcount{$g}++;
$dcount{$d}++;
}
close(UNIDATA);
while(<SIMP>) {
chop;
######################################################################
#
# Get value from fields
#
######################################################################
@f = split(/;/ , $_);
$simp{$f[0]} = $f[1];
$sccount{$f[1]}++;
}
close(SIMP);
sub GetClass{
my ($u) = @_;
my $hex = DecToHex($u);
$g = $gcat{$hex};
if($g ne "") {
return $g;
} elsif (( 0x4e00 <= $u) && ( $u <= 0x9fa5 ) ) {
return "Han";
} elsif (( 0xac00 <= $u) && ( $u <= 0xd7a3 ) ) {
return "Lo";
} elsif (( 0xd800 <= $u) && ( $u <= 0xdb7f ) ) {
return "Cs";
} elsif (( 0xdb80 <= $u) && ( $u <= 0xdbff ) ) {
return "Cs";
} elsif (( 0xdc00 <= $u) && ( $u <= 0xdfff ) ) {
return "Cs";
} elsif (( 0xe000 <= $u) && ( $u <= 0xf8ff ) ) {
return "Co";
} else {
printf "WARNNING !!!! Cannot find General Category for U+%s \n" , $hex;
}
}
sub GetDClass{
my ($u) = @_;
my $hex = DecToHex($u);
$g = $dcat{$hex};
if($g ne "") {
return $g;
} elsif (( 0x4e00 <= $u) && ( $u <= 0x9fa5 ) ) {
return "Han";
} elsif (( 0xac00 <= $u) && ( $u <= 0xd7a3 ) ) {
return "L";
} elsif (( 0xd800 <= $u) && ( $u <= 0xdb7f ) ) {
return "C";
} elsif (( 0xdb80 <= $u) && ( $u <= 0xdbff ) ) {
return "C";
} elsif (( 0xdc00 <= $u) && ( $u <= 0xdfff ) ) {
return "C";
} elsif (( 0xe000 <= $u) && ( $u <= 0xf8ff ) ) {
return "C";
} else {
printf "WARNNING !!!! Cannot find Detailed General Category for U+%s \n" , $hex;
}
}
sub DecToHex{
my ($d) = @_;
return sprintf("%04X", $d);
}
%gtotal = ();
%dtotal = ();
while(<CLASS>) {
chop;
######################################################################
#
# Get value from fields
#
######################################################################
@f = split(/;/ , $_);
if( substr($f[2], 0, 1) ne "a")
{
$sc = $simp{$f[2]};
$l = hex($f[0]);
if($f[1] eq "")
{
$h = $l;
} else {
$h = hex($f[1]);
}
for($k = $l; $k <= $h ; $k++)
{
if( exists($occ{$k}))
{
# printf "WARNING !! Conflict defination!!! U+%s -> [%s] [%s | %s]\n",
# DecToHex($k), $occ{$k} , $f[2] , $sc;
}
else
{
$occ{$k} = $sc . " | " . $f[2];
$gclass = GetClass($k);
$dclass = GetDClass($k);
$gtotal{$sc . $gclass}++;
$dtotal{$sc . $dclass}++;
$u = DecToHex($k);
$rk = " " . substr($u,0,2) . ":" . $sc;
$rangecount{$rk}++;
}
}
}
}
#print %gtotal;
#print %dtotal;
sub printreport
{
print OUT "<TABLE BORDER=3>\n";
print OUT "<TR BGCOLOR=blue><TH><TH>\n";
foreach $d (sort(keys %dcount)) {
print OUT "<TD BGCOLOR=red>$d</TD>\n";
}
print OUT "<TD BGCOLOR=white>Total</TD>\n";
foreach $g (sort(keys %gcount)) {
print OUT "<TD BGCOLOR=yellow>$g</TD>\n";
}
print OUT "</TR>\n";
foreach $sc (sort(keys %sccount)) {
print OUT "<TR><TH>$sc<TH>\n";
$total = 0;
foreach $d (sort (keys %dcount)) {
$count = $dtotal{$sc . $d};
$total += $count;
print OUT "<TD>$count</TD>\n";
}
print OUT "<TD BGCOLOR=white>$total</TD>\n";
foreach $g (sort(keys %gcount)) {
$count = $gtotal{$sc . $g};
print OUT "<TD>$count</TD>\n";
}
print OUT "</TR>\n";
}
print OUT "</TABLE>\n";
print OUT "<TABLE BORDER=3>\n";
print OUT "<TR BGCOLOR=blue><TH><TH>\n";
foreach $sc (sort(keys %sccount))
{
print OUT "<TD BGCOLOR=red>$sc</TD>\n";
}
print OUT "</TR>\n";
for($rr = 0; $rr < 0x4f; $rr++)
{
$empty = 0;
$r = sprintf("%02X" , $rr) ;
$tmp = "<TR><TH>" . $r . "<TH>\n";
foreach $sc (sort(keys %sccount)) {
$count = $rangecount{ " " .$r . ":" .$sc};
$tmp .= sprintf("<TD>%s</TD>\n", $count);
$empty += $count;
}
$tmp .= "</TR>\n";
if($empty ne 0)
{
print OUT $tmp;
}
}
print OUT "</TABLE>\n";
}
printreport();
sub printarray
{
my($r, $def) = @_;
printf "[%s || %s]\n", $r, $def;
$k = hex($r) * 256;
printf HEADER "static PRUint32 gLBClass%s[32] = {\n", $r;
for($i = 0 ; $i < 256; $i+= 8)
{
for($j = 7 ; $j >= 0; $j-- )
{
$v = $k + $i + $j;
if( exists($occ{$v}))
{
$p = substr($occ{$v}, 1,1);
} else {
$p = $def;
}
if($j eq 7 )
{
printf HEADER "0x%s" , $p;
} else {
printf HEADER "%s", $p ;
}
}
printf HEADER ", // U+%04X - U+%04X\n", $k + $i ,( $k + $i + 7);
}
print HEADER "};\n\n";
}
printarray("00", "8");
printarray("20", "8");
printarray("21", "8");
printarray("30", "5");
#print %rangecount;
######################################################################
#
# Close files
#
######################################################################
close(HEADER);
close(CLASS);
close(OUT);

View File

@ -0,0 +1,21 @@
1;00_1
2;01_[a]
3;01_[a]
4;01_[a]
5;01_[a]
6;01_[a]
7;02_7
8;03_8
9;04_9
10;05_[b]
11;05_[b]
12;05_[b]
13;X
14;X
15;06_15
16;07_16
17;05_[b]
18;08_18
19;X
20;X
21;09_nbsp