Changeset 13550
- Timestamp:
- 2007-01-10T14:00:02+13:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/GenericList.pm
r13340 r13550 233 233 $metadata_value =~ s/^\s*//; 234 234 $metadata_value =~ s/\s*$//; 235 push(@{$self->{$metadata_group . ".list"}->{$section_OID}}, $metadata_value); 235 236 # Convert the metadata value from a UTF-8 string to a Unicode string 237 # This means that length() and substr() work properly 238 # We need to be careful to convert classifier node title values back to UTF-8, however 239 my $metadata_value_unicode_string = &convert_utf8_string_to_unicode_string($metadata_value); 240 241 # Add the metadata value into the list for this combination of metadata group and section 242 push(@{$self->{$metadata_group . ".list"}->{$section_OID}}, $metadata_value_unicode_string); 236 243 } 237 244 last if (@metadata_values > 0); … … 305 312 my %metavaluetoOIDsubhash = (); 306 313 307 my $lastpartition = &unicode::substr($sortedmetavalues[0], 0, 1);314 my $lastpartition = substr($sortedmetavalues[0], 0, 1); 308 315 foreach my $metavalue (@sortedmetavalues) { 309 my $metavaluepartition = &unicode::substr($metavalue, 0, 1);316 my $metavaluepartition = substr($metavalue, 0, 1); 310 317 311 318 # Is this the start of a new partition? … … 371 378 372 379 373 sub unicode_length 374 { 375 my $utf8string = shift(@_); 376 377 my @unicodestring = @{&unicode::utf82unicode($utf8string)}; 378 return scalar(@unicodestring); 380 sub convert_utf8_string_to_unicode_string 381 { 382 my $utf8_string = shift(@_); 383 384 my $unicode_string = ""; 385 foreach my $unicode_value (@{&unicode::utf82unicode($utf8_string)}) { 386 $unicode_string .= chr($unicode_value); 387 } 388 return $unicode_string; 389 } 390 391 392 sub convert_unicode_string_to_utf8_string 393 { 394 my $unicode_string = shift(@_); 395 396 my @unicode_array; 397 for (my $i = 0; $i < length($unicode_string); $i++) { 398 push(@unicode_array, ord(substr($unicode_string, $i, 1))); 399 } 400 return &unicode::unicode2utf8(\@unicode_array); 379 401 } 380 402 … … 385 407 my $lastpartitionend = shift(@_); 386 408 387 my $partitionstart = &unicode::substr($metavalue, 0, 1);409 my $partitionstart = substr($metavalue, 0, 1); 388 410 if ($partitionstart le $lastpartitionend) { 389 $partitionstart = &unicode::substr($metavalue, 0, 2);411 $partitionstart = substr($metavalue, 0, 2); 390 412 # Give up after three characters 391 413 if ($partitionstart le $lastpartitionend) { 392 $partitionstart = &unicode::substr($metavalue, 0, 3);414 $partitionstart = substr($metavalue, 0, 3); 393 415 } 394 416 } … … 403 425 my $partitionstart = shift(@_); 404 426 405 my $partitionend = &unicode::substr($metavalue, 0, &unicode_length($partitionstart));427 my $partitionend = substr($metavalue, 0, length($partitionstart)); 406 428 if ($partitionend gt $partitionstart) { 407 $partitionend = &unicode::substr($metavalue, 0, 1);429 $partitionend = substr($metavalue, 0, 1); 408 430 if ($partitionend le $partitionstart) { 409 $partitionend = &unicode::substr($metavalue, 0, 2);431 $partitionend = substr($metavalue, 0, 2); 410 432 # Give up after three characters 411 433 if ($partitionend le $partitionstart) { 412 $partitionend = &unicode::substr($metavalue, 0, 3);434 $partitionend = substr($metavalue, 0, 3); 413 435 } 414 436 } … … 428 450 429 451 # Create an hlist partition 430 my %child_classifier_node = ( 'Title' => $partitionname,452 my %child_classifier_node = ( 'Title' => &convert_unicode_string_to_utf8_string($partitionname), 431 453 'childtype' => "VList", 432 454 'contains' => [] ); … … 471 493 # Otherwise create a sublist (bookshelf) for the metadata value 472 494 else { 473 my %child_classifier_node = ( 'Title' => $metavalue,495 my %child_classifier_node = ( 'Title' => &convert_unicode_string_to_utf8_string($metavalue), 474 496 'childtype' => "VList", 475 497 'contains' => [] );
Note:
See TracChangeset
for help on using the changeset viewer.