1
내 데스크톱에 다음 코드를 적어 두었습니다. 내 랩탑에 다운로드하여 다운로드 한 루비 (v1.9.3)를 실행하려고했지만 다음 오류가 발생했습니다. Ruby를 처음 사용했을 때 처음 사용했을 때와 관련이 있지만 Ruby를 처음 실행했을 때 데스크탑에서이 문제가 발생하지 않았다는 것은 확실합니다.in`initialize ': 문자열에 널 바이트가 포함되어 있음 Ruby
C:/Users/Downloads/vscript.rb:18:in 'initialize': string contains null byte (ArgumentError)
from C:/Users/Downloads/vscript.rb:18:in 'open'
from C:/Users/Downloads/vscript.rb:18:in 'main'
라인 (18)은 File.open
라인은 다음과 같습니다
File.open("filename", "r") do |f|
# Do while there are characters in the text file
f.each do |line|
# Checks to see if any parts in file match the regex and inform the user
if x = line.match(/\d\.\d\.\d{4}\.\d/)
puts "#{x} was found in the file."
end
end
end
'vscript.rb'의 인코딩은 무엇입니까? UTF-16은 아마도? –
BOM없이 UTF-8로 인코딩 됨 –
UTF-8이 맞습니까? UTF-8 텍스트에는 0 바이트가 없어야하지만 UTF-16에는 0 바이트가 많이 포함됩니다. –