rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | package Spreadsheet::ParseExcel::FmtUnicode; |
| 2 | |
| 3 | ############################################################################### |
| 4 | # |
| 5 | # Spreadsheet::ParseExcel::FmtUnicode - A class for Cell formats. |
| 6 | # |
| 7 | # Used in conjunction with Spreadsheet::ParseExcel. |
| 8 | # |
| 9 | # Copyright (c) 2009 John McNamara |
| 10 | # Copyright (c) 2006-2008 Gabor Szabo |
| 11 | # Copyright (c) 2000-2006 Kawai Takanori |
| 12 | # |
| 13 | # perltidy with standard settings. |
| 14 | # |
| 15 | # Documentation after __END__ |
| 16 | # |
| 17 | |
| 18 | use strict; |
| 19 | use warnings; |
| 20 | |
| 21 | use Unicode::Map; |
| 22 | use base 'Spreadsheet::ParseExcel::FmtDefault'; |
| 23 | |
| 24 | our $VERSION = '0.59'; |
| 25 | |
| 26 | #------------------------------------------------------------------------------ |
| 27 | # new (for Spreadsheet::ParseExcel::FmtUnicode) |
| 28 | #------------------------------------------------------------------------------ |
| 29 | sub new { |
| 30 | my ( $sPkg, %hKey ) = @_; |
| 31 | my $sMap = $hKey{Unicode_Map}; |
| 32 | my $oMap; |
| 33 | $oMap = Unicode::Map->new($sMap) if $sMap; |
| 34 | my $oThis = { |
| 35 | Unicode_Map => $sMap, |
| 36 | _UniMap => $oMap, |
| 37 | }; |
| 38 | bless $oThis; |
| 39 | return $oThis; |
| 40 | } |
| 41 | |
| 42 | #------------------------------------------------------------------------------ |
| 43 | # TextFmt (for Spreadsheet::ParseExcel::FmtUnicode) |
| 44 | #------------------------------------------------------------------------------ |
| 45 | sub TextFmt { |
| 46 | my ( $oThis, $sTxt, $sCode ) = @_; |
| 47 | if ( $oThis->{_UniMap} ) { |
| 48 | if ( !defined($sCode) ) { |
| 49 | my $sSv = $sTxt; |
| 50 | $sTxt =~ s/(.)/\x00$1/sg; |
| 51 | $sTxt = $oThis->{_UniMap}->from_unicode($sTxt); |
| 52 | $sTxt = $sSv unless ($sTxt); |
| 53 | } |
| 54 | elsif ( $sCode eq 'ucs2' ) { |
| 55 | $sTxt = $oThis->{_UniMap}->from_unicode($sTxt); |
| 56 | } |
| 57 | |
| 58 | # $sTxt = $oThis->{_UniMap}->from_unicode($sTxt) |
| 59 | # if(defined($sCode) && $sCode eq 'ucs2'); |
| 60 | return $sTxt; |
| 61 | } |
| 62 | else { |
| 63 | return $sTxt; |
| 64 | } |
| 65 | } |
| 66 | 1; |
| 67 | |
| 68 | __END__ |
| 69 | |
| 70 | =pod |
| 71 | |
| 72 | =head1 NAME |
| 73 | |
| 74 | Spreadsheet::ParseExcel::FmtUnicode - A class for Cell formats. |
| 75 | |
| 76 | =head1 SYNOPSIS |
| 77 | |
| 78 | See the documentation for Spreadsheet::ParseExcel. |
| 79 | |
| 80 | =head1 DESCRIPTION |
| 81 | |
| 82 | This module is used in conjunction with Spreadsheet::ParseExcel. See the documentation for Spreadsheet::ParseExcel. |
| 83 | |
| 84 | =head1 AUTHOR |
| 85 | |
| 86 | Maintainer 0.40+: John McNamara jmcnamara@cpan.org |
| 87 | |
| 88 | Maintainer 0.27-0.33: Gabor Szabo szabgab@cpan.org |
| 89 | |
| 90 | Original author: Kawai Takanori kwitknr@cpan.org |
| 91 | |
| 92 | =head1 COPYRIGHT |
| 93 | |
| 94 | Copyright (c) 2009-2010 John McNamara |
| 95 | |
| 96 | Copyright (c) 2006-2008 Gabor Szabo |
| 97 | |
| 98 | Copyright (c) 2000-2006 Kawai Takanori |
| 99 | |
| 100 | All rights reserved. |
| 101 | |
| 102 | You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. |
| 103 | |
| 104 | =cut |