回答編集履歴

1

対処療法

2018/07/14 04:36

投稿

asm
asm

スコア15147

test CHANGED
@@ -23,3 +23,39 @@
23
23
 
24
24
 
25
25
  このスクリプトを実行して日本語入力するとどうなりますでしょうか?
26
+
27
+
28
+
29
+
30
+
31
+ ----
32
+
33
+
34
+
35
+ **追記**
36
+
37
+
38
+
39
+ とりあえず、暫定的な対処療法としては
40
+
41
+
42
+
43
+ [String#scrub](https://docs.ruby-lang.org/ja/latest/method/String/i/scrub.html)
44
+
45
+ [String#encodeのinvalid,replaceオプション](https://docs.ruby-lang.org/ja/latest/method/String/i/encode.html)
46
+
47
+
48
+
49
+ ですかね
50
+
51
+
52
+
53
+ サンプル
54
+
55
+ ```ruby
56
+
57
+ puts gets.chomp.scrub('')
58
+
59
+ puts gets.chomp.encode("utf-8", invalid: :replace, replace: '')
60
+
61
+ ```