no warnings 'surrogate'; # surrogates can be inputs to this
use charnames ();
-our $VERSION = '0.54';
+our $VERSION = '0.55';
require Exporter;
my $property = $table =~ s/\.pl//r;
$property = $utf8::file_to_swash_name{$property};
my $to_adjust = defined $property
- && $utf8::SwashInfo{$property}{'format'} eq 'a';
+ && $utf8::SwashInfo{$property}{'format'} =~ / ^ a /x;
for (split /^/m, $list) {
my ($start, $end, $value) = / ^ (.+?) \t (.*?) \t (.+?)
$ /x;
my $decimal_start = hex $start;
my $decimal_end = ($end eq "") ? $decimal_start : hex $end;
+ $value = hex $value if $to_adjust
+ && $utf8::SwashInfo{$property}{'format'} eq 'ax';
if ($return_hash) {
foreach my $i ($decimal_start .. $decimal_end) {
$return{$i} = ($to_adjust)
# Otherwise, convert hex formatted list entries to decimal; add a
# 'Y' map for the missing value in binary properties, or
# otherwise, use the input map unchanged.
- $map = ($format eq 'x')
+ $map = ($format eq 'x' || $format eq 'ax')
? hex $map
: $format eq 'b'
? 'Y'
my ($start, $end, $value) = / ^ (.+?) \t (.*?) \t (.+?)
\s* ( \# .* )? $ /x;
$end = $start if $end eq "";
- push @list, [ hex $start, hex $end, $value ];
+ push @list, [ hex $start, hex $end, hex $value ];
}
# For these mappings, the file contains all the simple mappings,
for my $element (@list) {
$official .= "\n" if $official;
if ($element->[1] == $element->[0]) {
- $official .= sprintf "%04X\t\t%s", $element->[0], $element->[2];
+ $official .= sprintf "%04X\t\t%X", $element->[0], $element->[2];
}
else {
- $official .= sprintf "%04X\t%04X\t%s", $element->[0], $element->[1], $element->[2];
+ $official .= sprintf "%04X\t%04X\t%X", $element->[0], $element->[1], $element->[2];
}
}
}
next PROPERTY;
}
}
+ elsif ($full_name =~ # These maps are in hex
+ /(Simple_)?(Case_Folding|(Lower|Title|Upper)case_Mapping)/)
+ {
+ $invmap_ref->[$i] = sprintf("%X", $invmap_ref->[$i]);
+ }
elsif ($format eq 'ad' || $format eq 'ale') {
# The numerics in the returned map are stored as adjusted
my $RATIONAL_FORMAT = 'r';
my $STRING_FORMAT = 's';
my $ADJUST_FORMAT = 'a';
+my $HEX_ADJUST_FORMAT = 'ax';
my $DECOMP_STRING_FORMAT = 'c';
my $STRING_WHITE_SPACE_LIST = 'sw';
$RATIONAL_FORMAT => 'rational: an integer or a fraction',
$STRING_FORMAT => 'string',
$ADJUST_FORMAT => 'some entries need adjustment',
+ $HEX_ADJUST_FORMAT => 'mapped value in hex; some entries need adjustment',
$DECOMP_STRING_FORMAT => 'Perl\'s internal (Normalize.pm) decomposition mapping',
$STRING_WHITE_SPACE_LIST => 'string, but some elements are interpreted as a list; white space occurs only as list item separators'
);
my $next_value;
my $offset = 0;
+ my $output_value_in_hex = $self->isa('Map_Table')
+ && $self->format eq $HEX_ADJUST_FORMAT;
+
# Output each range as part of the here document.
RANGE:
for my $set ($range_list{$addr}->ranges) {
# output
if ($start != $end && ! $range_size_1) {
push @OUT, sprintf "%04X\t%04X", $start, $end;
- $OUT[-1] .= "\t$value" if $value ne "";
+ if ($value ne "") {
+ if ($output_value_in_hex) {
+ $OUT[-1] .= sprintf "\t%X", $value;
+ }
+ else {
+ $OUT[-1] .= "\t$value";
+ }
+ }
# Add a comment with the size of the range, if
# requested. Expand Tabs to make sure they all start
# Here, caller is ok with default output.
for (my $i = $start; $i <= $end; $i++) {
- push @OUT, sprintf "%04X\t\t%s\n", $i, $value;
+ if ($output_value_in_hex) {
+ push @OUT, sprintf "%04X\t\t%X\n", $i, $value;
+ }
+ else {
+ push @OUT, sprintf "%04X\t\t%s\n", $i, $value;
+ }
}
}
}
}
# If the output is to be adjusted, the format of the table that gets
- # output is actually 'a' instead of whatever it is stored internally
- # as.
+ # output is actually 'a' or 'ax' instead of whatever it is stored
+ # internally as.
my $output_adjusted = ($self->to_output_map == $OUTPUT_ADJUSTED);
if ($output_adjusted) {
- $format = $ADJUST_FORMAT;
+ if ($default_map eq $CODE_POINT) {
+ $format = $HEX_ADJUST_FORMAT;
+ }
+ else {
+ $format = $ADJUST_FORMAT;
+ }
}
$self->_set_format($format);
*max = *min;
/* Non-binary tables have a third entry: what the first element of the
- * range maps to */
+ * range maps to. The map for those currently read here is in hex */
if (wants_value) {
if (isBLANK(*l)) {
++l;
-
- /* The ToLc, etc table mappings are not in hex, and must be
- * corrected by adding the code point to them */
- if (typeto) {
- char *after_strtol = (char *) lend;
- *val = Strtol((char *)l, &after_strtol, 10);
- l = (U8 *) after_strtol;
- }
- else { /* Other tables are in hex, and are the correct result
- without tweaking */
flags = PERL_SCAN_SILENT_ILLDIGIT
| PERL_SCAN_DISALLOW_PREFIX
| PERL_SCAN_SILENT_NON_PORTABLE;
l += numlen;
else
*val = 0;
- }
}
else {
*val = 0;