From fac12daba9821a671531ed339bc097823ea85c9d Mon Sep 17 00:00:00 2001 From: fukachan Date: Thu, 12 Apr 2001 13:37:15 +0000 Subject: define look_japanese( $self, $buf ). It checks $buf looks to contain Japanese string or not. --- fml/lib/Mail/Bounce.pm | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/fml/lib/Mail/Bounce.pm b/fml/lib/Mail/Bounce.pm index 54f2d74c..b55a492d 100644 --- a/fml/lib/Mail/Bounce.pm +++ b/fml/lib/Mail/Bounce.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Bounce.pm,v 1.5 2001/04/12 10:46:47 fukachan Exp $ +# $FML: Bounce.pm,v 1.6 2001/04/12 12:06:11 fukachan Exp $ # package Mail::Bounce; @@ -104,6 +104,33 @@ sub reason } +my $RE_SJIS_C = '[\201-\237\340-\374][\100-\176\200-\374]'; +my $RE_SJIS_S = "($RE_SJIS_C)+"; +my $RE_EUC_C = '[\241-\376][\241-\376]'; +my $RE_EUC_S = "($RE_EUC_C)+"; +my $RE_JIN = '\033\$[\@B]'; +my $RE_JOUT = '\033\([BJ]'; + +my @REGEXP = ( + $RE_SJIS_C, + $RE_SJIS_S, + $RE_EUC_C, + $RE_EUC_S, + $RE_JIN, + $RE_JOUT, + ); + +sub look_japanese +{ + my ($self, $buf) = @_; + + for my $regexp (@REGEXP) { + return 1 if $buf =~ /$regexp/; + } + + 0; +} + =head1 AUTHOR -- cgit v1.2.1