sl@0: # sl@0: # Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: # All rights reserved. sl@0: # This component and the accompanying materials are made available sl@0: # under the terms of "Eclipse Public License v1.0" sl@0: # which accompanies this distribution, and is available sl@0: # at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: # sl@0: # Initial Contributors: sl@0: # Nokia Corporation - initial contribution. sl@0: # sl@0: # Contributors: sl@0: # sl@0: # Description: sl@0: # See line 99 of this file. sl@0: # sl@0: sl@0: if (@ARGV != 2 && @ARGV != 3) sl@0: { sl@0: print <; sl@0: $lineNumber++; sl@0: if ($line =~ /^(0[xX][\da-fA-F]{1,4})\s*(0[xX][\da-fA-F]{1,4}).*/) sl@0: { sl@0: $acceptLineNumber++; sl@0: my $foreign = $1; sl@0: my $unicode = hex($2); sl@0: if (exists ($lines{$unicode})) sl@0: { sl@0: print "ERROR: Unicode $unicode is reused by $lines{$unicode} and $foreign.\n"; sl@0: exit(1); sl@0: } sl@0: $lines{$unicode} = $foreign; sl@0: } sl@0: else sl@0: { sl@0: #print "Ignore line: $line"; sl@0: } sl@0: } sl@0: close IN2; sl@0: print "\nRead $ARGV[0] done.\n"; sl@0: print "$acceptLineNumber of $lineNumber lines accepted.\n\n"; sl@0: sl@0: sl@0: # read 4 byte input file sl@0: open (IN4, "<$ARGV[1]") or die ("Error: $ARGV[1] $!"); sl@0: $lineNumber = 0; sl@0: $acceptLineNumber = 0; sl@0: while (!eof(IN4)) sl@0: { sl@0: my $line = ; sl@0: $lineNumber++; sl@0: if ($line =~ /^(0[xX]8[1-4]3\d[\da-fA-F]{2}3\d)\s*(0[xX][\da-fA-F]{4}).*/) sl@0: { sl@0: $acceptLineNumber++; sl@0: my $foreign = $1; sl@0: my $unicode = hex($2); sl@0: if (exists ($lines{$unicode})) sl@0: { sl@0: print "ERROR: Unicode $unicode is reused by $lines{$unicode} and $foreign.\n"; sl@0: exit(1); sl@0: } sl@0: $lines{$unicode} = $foreign; sl@0: } sl@0: else sl@0: { sl@0: #print "Ignore line: $line"; sl@0: } sl@0: } sl@0: close IN4; sl@0: print "Read $ARGV[1] done.\n"; sl@0: print "$acceptLineNumber of $lineNumber lines accepted.\n\n"; sl@0: sl@0: sl@0: # write to output file sl@0: print "Write to $root...\n"; sl@0: open (CPP, ">$root") or die ("Error: Can't open cpp file"); sl@0: print CPP < sl@0: #include sl@0: #include "cp54936.h" sl@0: sl@0: const TUint8 KForeignReplacement = 0x5F; sl@0: sl@0: EOD sl@0: print CPP "const TUint32 KMappingTableUnicodeBmp2CP54936\[65536\] = \n"; sl@0: print CPP "\t\{\n\t"; sl@0: sl@0: my $bytecount = 0; sl@0: my $expectUnicode = 0; sl@0: while ($expectUnicode <= 0xFFFF) sl@0: { sl@0: if (exists ($lines{$expectUnicode})) sl@0: { sl@0: print CPP "$lines{$expectUnicode}, "; sl@0: } sl@0: else sl@0: { sl@0: print CPP "KForeignReplacement, "; sl@0: } sl@0: $bytecount += 4; sl@0: $expectUnicode++; sl@0: if (($expectUnicode % 16) == 0) sl@0: { sl@0: print CPP sprintf("// %04X - %04X\n\t", $expectUnicode-16, $expectUnicode-1); sl@0: } sl@0: } sl@0: print CPP "};\t"; sl@0: sl@0: $bytecount += 8; sl@0: print CPP "// total byte count = $bytecount\n"; sl@0: print "\nTotal byte count: $bytecount.\n"; sl@0: close CPP; sl@0: sl@0: print "\nDone.";