blob: f0368bc07869898f6fc3f2dbcc118f543f48f889 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001package 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
18use strict;
19use warnings;
20
21use Unicode::Map;
22use base 'Spreadsheet::ParseExcel::FmtDefault';
23
24our $VERSION = '0.59';
25
26#------------------------------------------------------------------------------
27# new (for Spreadsheet::ParseExcel::FmtUnicode)
28#------------------------------------------------------------------------------
29sub 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#------------------------------------------------------------------------------
45sub 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}
661;
67
68__END__
69
70=pod
71
72=head1 NAME
73
74Spreadsheet::ParseExcel::FmtUnicode - A class for Cell formats.
75
76=head1 SYNOPSIS
77
78See the documentation for Spreadsheet::ParseExcel.
79
80=head1 DESCRIPTION
81
82This module is used in conjunction with Spreadsheet::ParseExcel. See the documentation for Spreadsheet::ParseExcel.
83
84=head1 AUTHOR
85
86Maintainer 0.40+: John McNamara jmcnamara@cpan.org
87
88Maintainer 0.27-0.33: Gabor Szabo szabgab@cpan.org
89
90Original author: Kawai Takanori kwitknr@cpan.org
91
92=head1 COPYRIGHT
93
94Copyright (c) 2009-2010 John McNamara
95
96Copyright (c) 2006-2008 Gabor Szabo
97
98Copyright (c) 2000-2006 Kawai Takanori
99
100All rights reserved.
101
102You 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