But I have trouble displaying Chinese characters in StyledTextCtrl,
On Mac, the control accepts characters, but failed to save (could be
problems in my application, the file becomes empty)
on Windows, typed or copied chinese characters showed as blocks,
failed to save as well.
I did a search ‘Unicode’ in this forum, couldn’t find relevant posts.
Scintilla defaults to the system’s encoding, so if you have a different
encoding from your target encoding, it won’t work. Try using thoes
methods,
and see if it makes any difference when your getting text from the
Scintilla
control.
def initialize
super
# ...
self.set_code_page(STC_CP_UTF8)
# ...
end
def save_file(name)
puts "calling save file #{name} "
begin
super
puts "saved Ok"
# ...
rescue => e
puts "error: saving file: #{e}"
logger.warn "failed to save #{name}: #{e}"
end
end
Output:
calling save file F:/samples/chinese_spec.rb
saved Ok
Then the file content is cleared.
Zhimin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.