www.pudn.com > sdk_host_2520.rar > build_pdm_files.pl
#;///////////////////////////////////////////////////////////////////////////////
#; Copyright(C) SigmaTel, Inc. 2000-2001
#;
#; Filename: build_PDM_files.pl
#; Description: Create "PDM_xx.SRC" files and resource linker include file (PDM.inc)
# needed for creating the Primary DBCS Map (PDM) resource file.
# Also, generate SDMs.inc, for use in creating Secondary DBCS Map resources.
#
#;///////////////////////////////////////////////////////////////////////////////
use vars qw($tool_dir);
use strict;
#;///////////////////////////////////////////////////////////////////////////////
#;> Name: build_PDM_files
#;
#; Type: Function
#; Prototype: build_PDM_files($PrimaryDBCSMapRef, $defaultUnicodeChar);
#
#; Description: Create "PDM_xx.SRC" files and resource linker include file (PDM.inc)
# needed for creating the Primary DBCS Map (PDM) resource file.
#
#; Inputs: $PrimaryDBCSMapRef - Reference to Primary DBCS Map (a hash)
# $defaultUnicodeChar - Default Unicode character: use when no
# mapping is defined.
#; Outputs:
#; Notes:
# PrimaryDBCSMapRef is a reference to a hash that described the mapping
# of DBCS characters. Hash keys are two digit hex values (0x00-0xff).
# If the value of the hash for some key is not defined, treat that key
# as a single byte character (SBC) and use the defaultUnicodeChar as its
# value.
#
# If the hash at some key is a scalar, treat it as a SBC and use the scalar
# value as the Unicode character.
#
# If the hash as some key is a reference, it should refer to another hash.
# Treat the key as a Lead Byte. The referenced hash is indexed by a second
# set of two digit hex values (keys), which map the Trailing Byte to some
# Unicode character (following the same rules for SBCs, above - i.e. if
# not defined, use the defaultUnicodeChar).
#;<
#;///////////////////////////////////////////////////////////////////////////////
sub build_PDM_files() {
my $PrimaryDBCSMapRef = shift;
my $defaultUnicodeChar = shift;
my $line;
my $default_script_index;
my $default_glyph_index;
my $Unicode_prefix;
my $script_index;
my %PDM;
my $file_prefix;
open PDM_INC_FILE, ">PDM.inc" || die "Can't open file: PDM.inc\n";
my $PDM_count = 0;
my $SDMs_count = 0;
for (my $charCode=0; $charCode<=0xff; $charCode++) {
printf PDM_INC_FILE "PDM_%02x\tequ\t%d\t;\$FILENAME PDM_%02x.src\n",
$charCode, 1+ $PDM_count++, $charCode;
if (defined $$PrimaryDBCSMapRef{$charCode}) {
if (ref $$PrimaryDBCSMapRef{$charCode}) { # MBC
generate_PDM_SDM_MBC_src("PDM", $charCode, $SDMs_count++);
}
else { # SBC
generate_PDM_SDM_SBC_src("PDM", $charCode, $$PrimaryDBCSMapRef{$charCode});
}
}
else { # UNDEFINED
generate_PDM_SDM_SBC_src("PDM", $charCode, $defaultUnicodeChar);
}
}
close PDM_INC_FILE;
}
1;
#;///////////////////////////////////////////////////////////////////////////////
#;///////////////////////////////////////////////////////////////////////////////
#;///////////////////////////////////////////////////////////////////////////////