質問編集履歴
3
コードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,17 +44,15 @@
|
|
44
44
|
|
45
45
|
```ここに言語を入力
|
46
46
|
|
47
|
-
sub b
|
47
|
+
sub z_substr {
|
48
48
|
|
49
|
-
my $str = $name;
|
50
49
|
|
51
|
-
my $length = length $str;
|
52
50
|
|
53
51
|
local($s,$p,$l) = @_;
|
54
52
|
|
55
|
-
$s =~ s/(.)/$1\0/g;
|
53
|
+
$s =~ s/(.)/$1\0/g;
|
56
54
|
|
57
|
-
$s =~ s/([\x81-\x9f\xe0-\xfc])\0(.)\0/$1$2\0\0/g;
|
55
|
+
$s =~ s/([\x81-\x9f\xe0-\xfc])\0(.)\0/$1$2\0\0 /g;
|
58
56
|
|
59
57
|
$s = $l eq '' ? substr($s,$p*2):substr($s,$p*2,$l*2);
|
60
58
|
|
@@ -62,11 +60,23 @@
|
|
62
60
|
|
63
61
|
$s;
|
64
62
|
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
sub bunkatsu {
|
68
|
+
|
69
|
+
my $str = $name;
|
70
|
+
|
71
|
+
my $length = length $str;
|
72
|
+
|
73
|
+
|
74
|
+
|
65
75
|
if ($length =10) {
|
66
76
|
|
67
|
-
$leftname = substr($s, 0, 5);
|
77
|
+
$leftname = &z_substr($str, 0, 5);
|
68
78
|
|
69
|
-
$rightname = substr($s, length($s) - 5, 5);
|
79
|
+
$rightname = &z_substr($str, length($str) - 5, 5);
|
70
80
|
|
71
81
|
}
|
72
82
|
|
2
質問の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,17 +16,21 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
|
19
|
+
local($s,$p,$l) = @_;
|
20
20
|
|
21
|
-
|
21
|
+
$s =~ s/(.)/$1\0/g;
|
22
22
|
|
23
|
-
|
23
|
+
$s =~ s/([\x81-\x9f\xe0-\xfc])\0(.)\0/$1$2\0\0/g;
|
24
24
|
|
25
|
-
$le
|
25
|
+
$s = $l eq '' ? substr($s,$p*2):substr($s,$p*2,$l*2);
|
26
26
|
|
27
|
-
$
|
27
|
+
$s =~ tr/\0//d;
|
28
28
|
|
29
|
+
$s;
|
30
|
+
|
31
|
+
こちらを入れると文字化けが対応できるとのことですが、
|
32
|
+
|
29
|
-
|
33
|
+
文字化けの解消がされませんでした。
|
30
34
|
|
31
35
|
|
32
36
|
|
1
コードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,17 +44,25 @@
|
|
44
44
|
|
45
45
|
my $str = $name;
|
46
46
|
|
47
|
-
my $decoded_str = Encode::decode('Shift_JIS', $str);
|
48
|
-
|
49
47
|
my $length = length $str;
|
50
48
|
|
49
|
+
local($s,$p,$l) = @_;
|
50
|
+
|
51
|
+
$s =~ s/(.)/$1\0/g;
|
52
|
+
|
51
|
-
|
53
|
+
$s =~ s/([\x81-\x9f\xe0-\xfc])\0(.)\0/$1$2\0\0/g;
|
54
|
+
|
55
|
+
$s = $l eq '' ? substr($s,$p*2):substr($s,$p*2,$l*2);
|
56
|
+
|
57
|
+
$s =~ tr/\0//d;
|
58
|
+
|
59
|
+
$s;
|
52
60
|
|
53
61
|
if ($length =10) {
|
54
62
|
|
55
|
-
$leftname = substr($
|
63
|
+
$leftname = substr($s, 0, 5);
|
56
64
|
|
57
|
-
$rightname = substr($
|
65
|
+
$rightname = substr($s, length($s) - 5, 5);
|
58
66
|
|
59
67
|
}
|
60
68
|
|