diff -r 4122176ea935 -r 56f325a607ea userlibandfileserver/fatfilenameconversionplugins/group/cp54936_4byte_tounicode.pl --- a/userlibandfileserver/fatfilenameconversionplugins/group/cp54936_4byte_tounicode.pl Mon Dec 21 16:14:42 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,176 +0,0 @@ -# -# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# See line 111 of this file. -# - -if (@ARGV != 1 && @ARGV != 2) - { - print <; - $lineNumber++; - if ($line =~ /^(0[xX]8[1-4]3\d[\da-fA-F]{2}3\d)\s*(0[xX][\da-fA-F]{4}).*/) - { - # read a line like "0x81318133 0x060D" - $acceptLineNumber++; - my $foreign = $1; - my $unicode = $2; - $lines{$foreign} = $unicode; - } - else - { - #print "Ignore line: $line"; - } - } -close IN; -print "Read $ARGV[0] done.\n"; -print "$acceptLineNumber of $lineNumber lines accepted.\n"; - - -# increase input cp54936 code by 1 -# param is a string like "0x81308439" -# return a string like "0x81308530" -sub IncreaseCP54936Code - { - my ($increaseme) = @_; - $increaseme =~ /0[xX]([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/; - ($b1, $b2, $b3, $b4) = (hex($1), hex($2), hex($3), hex($4)); - $b4++; - if ($b4 == 0x3A) - { - $b4 = 0x30; - $b3++; - if ($b3 == 0xFF) - { - $b3 = 0x81; - $b2++; - if ($b2 == 0x3A) - { - $b2 = 0x30; - $b1++; - } - } - } - return sprintf("0x%02X%02X%02X%02X", $b1, $b2, $b3, $b4); - } - -# return the offset from 0x81308130 to input "0x8234A235" -sub OffsetOfCP54936Code - { - $_[0] =~ /0[xX]([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/; - ($b1, $b2, $b3, $b4) = (hex($1), hex($2), hex($3), hex($4)); - return ($b1-0x81)*12600 + ($b2-0x30)*1260 + ($b3-0x81)*10 + ($b4-0x30); - } - -# return the last byte of input "0x8234A235" -sub Byte4OfCP54936Code - { - $_[0] =~ /0[xX]([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/; - return hex($4); - } - - -print "Write to $root.cpp...\n"; -open (CPP, ">$root.cpp") or die ("Error: $ARGV[0] Can't open cpp file"); - -print CPP < -#include -#include "cp54936.h" - - -// mapping table of: CP54936 4-byte in-BMP ---> Unicode -// To calculate index: index=(b1-144)*12600+(b2-48)*1260+(b3-129)*10+(b4-48), in which, -// b1,b2,b3,b4 is byte1,2,3,4 of CP54936 code. -// For example, CP54936 code 0x8232EA38, the index=(0x82-144)*12600+(0x32-48)*1260+(0xEA-129)*10+(0x38-48)=16178 -// So we get the Unicode 0x42AB. -// Generated with: \"perl -w ..\\group\\cp54936_4byte_tounicode.pl cp54936_4byte.txt cp54936_4byte_tounicode.cpp\". - -EOD - -my $bytecount = 0; -my $expect = "0x81308130"; -my $last = "0x8431A439"; -my $totalCount = OffsetOfCP54936Code($last) + 1; - - -print CPP "const TUint16 KMappingTable4ByteBmp2Unicode[$totalCount] =\n\t{\n\t"; - -my $outIndex = 0; # to wrap every 10 items -while (OffsetOfCP54936Code($expect) <= OffsetOfCP54936Code($last)) - { - if (!exists($lines{$expect})) - { - print CPP "0xFFFD, "; - } - else - { - print CPP "$lines{$expect}, "; - } - $bytecount += 2; - $outIndex++; - if ($outIndex % 10 == 0) - { - print CPP "\t// $expect\n\t"; - } - # to next foreign - $expect = IncreaseCP54936Code($expect); - } - -print CPP "};\n"; -print CPP "// total byte count = $bytecount\n"; -print "\nTotal byte count: $bytecount.\n"; -close CPP; -print "Done.\n";