From 918e478c5efd822f6f305f9f806ea1d4e2563f2d Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Thu, 1 Sep 2022 16:16:15 +0900 Subject: [PATCH] FileWrapper::WindowsFile: Support encoding parameter Signed-off-by: Takuro Ashie --- lib/fluent/file_wrapper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/fluent/file_wrapper.rb b/lib/fluent/file_wrapper.rb index 383862671f..3e4fe19784 100644 --- a/lib/fluent/file_wrapper.rb +++ b/lib/fluent/file_wrapper.rb @@ -47,9 +47,11 @@ class WindowsFile INVALID_HANDLE_VALUE = -1 - def initialize(path, mode='r') + def initialize(path, mode_enc='r') @path = path + mode, enc = mode_enc.split(":", 2) @io = File.open(path, mode2flags(mode)) + @io.set_encoding(enc) if enc @file_handle = Win32API._get_osfhandle(@io.to_i) @io.instance_variable_set(:@file_index, self.ino) def @io.ino