STC encoding

i’d like to use StyledTextCtrl in my aplication, to edit Watir tests.

But i have a great problem with encoding, i work on windows xp
(unfortunately) and all tests i have had been written in utf-8, in
NetBeans.

When i open a file in my own editor i see characters like “uĹĽy” instead
of polish characters.
When i type in my own editor i can use polish characters, and they are
displayed good.
When i edit a file and save it, i see “��” instead of polish characters.

I have tried a lot of combinations with:

@sci.style_set_character_set(STC_STYLE_DEFAULT, 0)
@sci.set_code_page(65001)
@sci.style_set_font_encoding(STC_STYLE_DEFAULT, FONTENCODING_UTF8)
Font.set_default_encoding(FONTENCODING_UTF8)
but it didnt help

if i use File.new to create a file and File.puts contents inside of it,
and load this script into my editor i see wrongly displayed polish
characters, but when i run a test i get correct characters in output, so
the problem is when i write sth and save it.

–code for load and save–

evt_button(@button_edit_bottom.get_id()){
|event|
file_to_edit = @listbox_added.get_selections()
file_to_edit = file_to_edit[0]
file_to_edit = $tests[file_to_edit]
@sci.load_file("#{file_to_edit}")
@input_edit_save.set_value("#{file_to_edit}")
}
evt_button(@button_edit_save.get_id()){
|event|
edited_file_to_save = @input_edit_save.get_line_text(0)
if edited_file_to_save != “”
f = File.new("#{edited_file_to_save}",“w”) if
File.exists?("#{edited_file_to_save}") == false
@sci.save_file("#{edited_file_to_save}")
file_to_reedit = @input_edit_save.get_line_text(0)
@sci.load_file("#{file_to_reedit}")
@input_edit_save.set_value("#{file_to_reedit}")
else
@mdialog_input_edit_save = MessageDialog.new(@my_panel,
“Name the file please”, “Oops!”, OK, DEFAULT_POSITION)
@mdialog_input_edit_save.show_modal()
end
}

the problem seams to be related to load_file and save_file.

        f = File.new("#{edited_file_to_save}","w+")
        f.each do |line|
          line.delete
        end
        contents_to_save = @sci.get_text#tu
        f.puts contents_to_save
        f.close

works for me

AFAIK

Opening in ‘w’ mode truncates existing file to zero length, or create
new file. ‘w+’ is same but allow to read the file too. so, in both cases
file is clear upon opening.

line.delete does nothing there. f.each yelds lines of text read from the
file, String instances. Whatever you do with them, it does not change
the file.

28.05.2010, × 17:14, Maciej S. ÎÁÐÉÓÁÌ(Á):

works for me

Posted via http://www.ruby-forum.com/.


wxruby-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wxruby-users

Sergey C.
[email protected]