commit beeae7c6e260d3ea5b262fac2d1096c2c8858514
parent 39289820a7a9573d0ca830ce0cb2881deba87aa8
Author: Dan Callaghan <djc@djc.id.au>
Date: Sun, 11 May 2025 16:09:00 +1000
use $encoding for drafts instead of forcing UTF-8
If the user's locale charset is not UTF-8 (unlikely) let's respect that,
instead of forcing drafts to always be treated as UTF-8.
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/sup/draft.rb b/lib/sup/draft.rb
@@ -16,7 +16,7 @@ class DraftManager
def write_draft
offset = @source.gen_offset
fn = @source.fn_for_offset offset
- File.open(fn, "w:UTF-8") { |f| yield f }
+ File.open(fn, "w", :encoding => $encoding) { |f| yield f }
PollManager.poll_from @source
end
@@ -85,7 +85,7 @@ class DraftLoader < Source
def raw_header offset
ret = ""
- File.open(fn_for_offset(offset), "r:UTF-8") do |f|
+ File.open(fn_for_offset(offset), "r") do |f|
until f.eof? || (l = f.gets) =~ /^$/
ret += l
end
@@ -94,13 +94,13 @@ class DraftLoader < Source
end
def each_raw_message_line offset
- File.open(fn_for_offset(offset), "r:UTF-8") do |f|
+ File.open(fn_for_offset(offset), "r") do |f|
yield f.gets until f.eof?
end
end
def raw_message offset
- IO.read(fn_for_offset(offset), :encoding => "UTF-8")
+ IO.read fn_for_offset(offset)
end
def start_offset; 0; end