Forum: wxRuby STC encoding

509e3a9f710f3715fe165718efb7702c?d=identicon&s=25 Maciej Szatanik (mszatanik)
on 2010-05-28 12:58
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

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.style_set_font_encoding(STC_STYLE_DEFAULT, FONTENCODING_UTF8)
but it didnt help

if i use 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--

          file_to_edit = @listbox_added.get_selections()
          file_to_edit = file_to_edit[0]
          file_to_edit = $tests[file_to_edit]
          edited_file_to_save = @input_edit_save.get_line_text(0)
          if edited_file_to_save != ""
            f ="#{edited_file_to_save}","w") if
File.exists?("#{edited_file_to_save}") == false
            file_to_reedit = @input_edit_save.get_line_text(0)
            @mdialog_input_edit_save =,
"Name the file please", "Oops!", OK, DEFAULT_POSITION)
509e3a9f710f3715fe165718efb7702c?d=identicon&s=25 Maciej Szatanik (mszatanik)
on 2010-05-28 15:14
the problem seams to be related to load_file and save_file.

            f ="#{edited_file_to_save}","w+")
            f.each do |line|
            contents_to_save = @sci.get_text#tu
            f.puts contents_to_save

works for me
7e3a56ff8a090fc9ffbd1909dea94904?d=identicon&s=25 Sergey Chernov (sergeych)
on 2010-06-06 01:44
(Received via mailing list)

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 Szatanik ÎÁÐÉÓÁÌ(Á):

> works for me
> --
> Posted via
> _______________________________________________
> wxruby-users mailing list

Sergey Chernov
This topic is locked and can not be replied to.