0
|
1 |
# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
# All rights reserved.
|
|
3 |
# This component and the accompanying materials are made available
|
|
4 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
# which accompanies this distribution, and is available
|
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
#
|
|
8 |
# Initial Contributors:
|
|
9 |
# Nokia Corporation - initial contribution.
|
|
10 |
#
|
|
11 |
# Contributors:
|
|
12 |
#
|
|
13 |
# Description:
|
|
14 |
# See line 99 of this file.
|
|
15 |
#
|
|
16 |
|
|
17 |
if (@ARGV != 2 && @ARGV != 3)
|
|
18 |
{
|
|
19 |
print <<EOD;
|
|
20 |
Usage: cp54936_allbmp_fromunicode.pl cp54936_2byte.txt cp54936_4byte.txt cp54936_allbmp_fromunicode.cpp
|
|
21 |
EOD
|
|
22 |
exit(1);
|
|
23 |
}
|
|
24 |
|
|
25 |
my $root = "cp54936_allbmp_fromunicode.cpp";
|
|
26 |
if (@ARGV == 3)
|
|
27 |
{
|
|
28 |
$root = $ARGV[3];
|
|
29 |
}
|
|
30 |
|
|
31 |
|
|
32 |
my %lines; # the hash table to hold all characters with key=unicode(dec) and value=foreign(string)
|
|
33 |
|
|
34 |
|
|
35 |
# read 2 byte input file
|
|
36 |
open (IN2, "<$ARGV[0]") or die ("Error: $ARGV[0] $!");
|
|
37 |
my $lineNumber = 0;
|
|
38 |
my $acceptLineNumber = 0;
|
|
39 |
while (!eof(IN2))
|
|
40 |
{
|
|
41 |
my $line = <IN2>;
|
|
42 |
$lineNumber++;
|
|
43 |
if ($line =~ /^(0[xX][\da-fA-F]{1,4})\s*(0[xX][\da-fA-F]{1,4}).*/)
|
|
44 |
{
|
|
45 |
$acceptLineNumber++;
|
|
46 |
my $foreign = $1;
|
|
47 |
my $unicode = hex($2);
|
|
48 |
if (exists ($lines{$unicode}))
|
|
49 |
{
|
|
50 |
print "ERROR: Unicode $unicode is reused by $lines{$unicode} and $foreign.\n";
|
|
51 |
exit(1);
|
|
52 |
}
|
|
53 |
$lines{$unicode} = $foreign;
|
|
54 |
}
|
|
55 |
else
|
|
56 |
{
|
|
57 |
#print "Ignore line: $line";
|
|
58 |
}
|
|
59 |
}
|
|
60 |
close IN2;
|
|
61 |
print "\nRead $ARGV[0] done.\n";
|
|
62 |
print "$acceptLineNumber of $lineNumber lines accepted.\n\n";
|
|
63 |
|
|
64 |
|
|
65 |
# read 4 byte input file
|
|
66 |
open (IN4, "<$ARGV[1]") or die ("Error: $ARGV[1] $!");
|
|
67 |
$lineNumber = 0;
|
|
68 |
$acceptLineNumber = 0;
|
|
69 |
while (!eof(IN4))
|
|
70 |
{
|
|
71 |
my $line = <IN4>;
|
|
72 |
$lineNumber++;
|
|
73 |
if ($line =~ /^(0[xX]8[1-4]3\d[\da-fA-F]{2}3\d)\s*(0[xX][\da-fA-F]{4}).*/)
|
|
74 |
{
|
|
75 |
$acceptLineNumber++;
|
|
76 |
my $foreign = $1;
|
|
77 |
my $unicode = hex($2);
|
|
78 |
if (exists ($lines{$unicode}))
|
|
79 |
{
|
|
80 |
print "ERROR: Unicode $unicode is reused by $lines{$unicode} and $foreign.\n";
|
|
81 |
exit(1);
|
|
82 |
}
|
|
83 |
$lines{$unicode} = $foreign;
|
|
84 |
}
|
|
85 |
else
|
|
86 |
{
|
|
87 |
#print "Ignore line: $line";
|
|
88 |
}
|
|
89 |
}
|
|
90 |
close IN4;
|
|
91 |
print "Read $ARGV[1] done.\n";
|
|
92 |
print "$acceptLineNumber of $lineNumber lines accepted.\n\n";
|
|
93 |
|
|
94 |
|
|
95 |
# write to output file
|
|
96 |
print "Write to $root...\n";
|
|
97 |
open (CPP, ">$root") or die ("Error: Can't open cpp file");
|
|
98 |
print CPP <<EOD;
|
|
99 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
100 |
// All rights reserved.
|
|
101 |
// This component and the accompanying materials are made available
|
|
102 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
103 |
// which accompanies this distribution, and is available
|
|
104 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
105 |
//
|
|
106 |
// Initial Contributors:
|
|
107 |
// Nokia Corporation - initial contribution.
|
|
108 |
//
|
|
109 |
// Contributors:
|
|
110 |
//
|
|
111 |
// Description:
|
|
112 |
//
|
|
113 |
// Generated by the cp54936_allbmp_fromunicode.pl tool - Do not edit!!!
|
|
114 |
// Generated with \"perl -w ..\\group\\cp54936_allbmp_fromunicode.pl cp54936_2byte.txt cp54936_4byte.txt\".
|
|
115 |
//
|
|
116 |
|
|
117 |
#include <e32std.h>
|
|
118 |
#include <e32def.h>
|
|
119 |
#include "cp54936.h"
|
|
120 |
|
|
121 |
const TUint8 KForeignReplacement = 0x5F;
|
|
122 |
|
|
123 |
EOD
|
|
124 |
print CPP "const TUint32 KMappingTableUnicodeBmp2CP54936\[65536\] = \n";
|
|
125 |
print CPP "\t\{\n\t";
|
|
126 |
|
|
127 |
my $bytecount = 0;
|
|
128 |
my $expectUnicode = 0;
|
|
129 |
while ($expectUnicode <= 0xFFFF)
|
|
130 |
{
|
|
131 |
if (exists ($lines{$expectUnicode}))
|
|
132 |
{
|
|
133 |
print CPP "$lines{$expectUnicode}, ";
|
|
134 |
}
|
|
135 |
else
|
|
136 |
{
|
|
137 |
print CPP "KForeignReplacement, ";
|
|
138 |
}
|
|
139 |
$bytecount += 4;
|
|
140 |
$expectUnicode++;
|
|
141 |
if (($expectUnicode % 16) == 0)
|
|
142 |
{
|
|
143 |
print CPP sprintf("// %04X - %04X\n\t", $expectUnicode-16, $expectUnicode-1);
|
|
144 |
}
|
|
145 |
}
|
|
146 |
print CPP "};\t";
|
|
147 |
|
|
148 |
$bytecount += 8;
|
|
149 |
print CPP "// total byte count = $bytecount\n";
|
|
150 |
print "\nTotal byte count: $bytecount.\n";
|
|
151 |
close CPP;
|
|
152 |
|
|
153 |
print "\nDone.";
|