News:

Congratulations!
 You've won the News Item Lottery! Your prize? Reading this news item! :)

Patch to remove utf_encoded which is effectively a constant

Started by Ters, September 12, 2015, 02:16:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ters

During my study of Simutrans' handling of character encodings, I noticed that Simutrans always stores translated strings as UTF-8, unless a hidden compile-time switch is changed. There is also another related compile-time switch in the text rendering. Neither can be configured as a build parameter, one has to alter files to toggle them. Seeing no reason why anyone would ever want to switch these to non-unicode, I have made a patch that removed them. This in turn means that two runtime-flags for using UTF-8 become constants, so the patch removes the flags and all uses of them as well.

There are two things I am not quite sure about when it comes to this patch. First of all, as it currently is, the runtime-flags are only set after selecting a pak set. Before that, Simutrans does not operate in Unicode mode. With this patch, it will. This means that the names of pak set folders must be in 7-bit ASCII in order to be presentable, at least until the issue with Unicode paths are resolved. I don't think non-ASCII pak set directory names were without problems earlier either, but at least Latin 1 on Windows worked, if only by accident.

The other issue is an if block in gui_textinput.cc. The condition currently says if(  uc <= 128  ||  ! translator::get_lang()->utf_encoded  ). I have removed the second part, but I can't see how the code inside the block makes sense in a Unicode environment. Someone should perhaps take a look at it whether this patch is accepted or not.

I hope this patch includes everything I did, and nothing of the other changes I have done.

prissi