blob: 318cb01fa810393ff14edd29799a9157bbbd0723 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001package Spreadsheet::ParseExcel::FmtJapan2;
2
3###############################################################################
4#
5# Spreadsheet::ParseExcel::FmtJapan2 - 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 Jcode;
22use Unicode::Map;
23use base 'Spreadsheet::ParseExcel::FmtJapan';
24our $VERSION = '0.59';
25
26#------------------------------------------------------------------------------
27# new (for Spreadsheet::ParseExcel::FmtJapan2)
28#------------------------------------------------------------------------------
29sub new {
30 my ( $sPkg, %hKey ) = @_;
31 my $oMap = Unicode::Map->new('CP932Excel');
32 die "NO MAP FILE CP932Excel!!"
33 unless ( -r Unicode::Map->mapping("CP932Excel") );
34
35 my $oThis = {
36 Code => $hKey{Code},
37 _UniMap => $oMap,
38 };
39 bless $oThis;
40 $oThis->SUPER::new(%hKey);
41 return $oThis;
42}
43
44#------------------------------------------------------------------------------
45# TextFmt (for Spreadsheet::ParseExcel::FmtJapan2)
46#------------------------------------------------------------------------------
47sub TextFmt {
48 my ( $oThis, $sTxt, $sCode ) = @_;
49
50 # $sCode = 'sjis' if((! defined($sCode)) || ($sCode eq '_native_'));
51 if ( $oThis->{Code} ) {
52 if ( !defined($sCode) ) {
53 $sTxt =~ s/(.)/\x00$1/sg;
54 $sTxt = $oThis->{_UniMap}->from_unicode($sTxt);
55 }
56 elsif ( $sCode eq 'ucs2' ) {
57 $sTxt = $oThis->{_UniMap}->from_unicode($sTxt);
58 }
59 return Jcode::convert( $sTxt, $oThis->{Code}, 'sjis' );
60 }
61 else {
62 return $sTxt;
63 }
64}
651;
66
67__END__
68
69=pod
70
71=head1 NAME
72
73Spreadsheet::ParseExcel::FmtJapan2 - A class for Cell formats.
74
75=head1 SYNOPSIS
76
77See the documentation for Spreadsheet::ParseExcel.
78
79=head1 DESCRIPTION
80
81This module is used in conjunction with Spreadsheet::ParseExcel. See the documentation for Spreadsheet::ParseExcel.
82
83=head1 AUTHOR
84
85Maintainer 0.40+: John McNamara jmcnamara@cpan.org
86
87Maintainer 0.27-0.33: Gabor Szabo szabgab@cpan.org
88
89Original author: Kawai Takanori kwitknr@cpan.org
90
91=head1 COPYRIGHT
92
93Copyright (c) 2009-2010 John McNamara
94
95Copyright (c) 2006-2008 Gabor Szabo
96
97Copyright (c) 2000-2006 Kawai Takanori
98
99All rights reserved.
100
101You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
102
103=cut