on the Turkish characters and the other non-ascii chracters

Discussion among members of the development team.

Moderators: Forum Moderators, Developers

Post Reply
ihsan
Posts: 30
Joined: March 1st, 2005, 4:26 pm
Location: Istanbul, TURKEY

on the Turkish characters and the other non-ascii chracters

Post by ihsan »

In chat of the multiplayer game, we cannot write the Turkish characters

ğ Ğ ı İ

I've looked over the source code and make some compilaiton and here the resuls.

at first I checked that whether the textbox can display them or not;
result is they can display.

then, I looked at what happen the key strokes, and I saw that the characters get value 0, in the funciton

textbox::handle_event(const SDL_Event& event) {

in the line

wchar_t character = key.unicode;

where as key.sym method gets a correct value, at least distint.

I've tried

wchar_t character= 'Ş';

but this was showed only box not the character and also I get a compilation warning too. That is;

warning: multi-character character constant

at this point I'm stuck and need some help.

İhsan.
Westnoth is ruled by anNOYing King of Dragons
ryn
Posts: 196
Joined: August 23rd, 2004, 4:01 am
Location: Israel

Post by ryn »

Well, unfortunately, I cannot help you much, but I can say that I would most certainly support such code; it appears as though Hebrew cannot be typed either, which would make a translation somewhat pointless (chatting is important).
2B |! 2B = 3F
torangan
Retired Developer
Posts: 1365
Joined: March 27th, 2004, 12:25 am
Location: Germany

Post by torangan »

Ihsan: while I don't know about the specific Wesnoth/SDL code I can tell you that C++ doesn't allow unicode in ''. Those specify a char which is usually a 8 bit type. Most likely you'll never work on a system where it is not. For unicode you'd have to use something like
char character[4] = { 0x??, 0x??, 0x??, 0x?? }
depending on wheter you use UTF32 or UTF8/16 whatever it is of course a different amount of bytes that's required. IIRC correctly Wesnoth uses UTF8 internally as well so it'd be one to five or six bytes :?: I don't know exactly how long the latest characters are already in UTF8. If wchar_t has the required size you can of course use that as well as an char array. In fact, use whatever makes the least trouble with SDL and assign each byte the correct value for the character you need.

Ryn: if you intend to work upon a hebrew translation, just contact the developers and I'm sure they'll work on adding support for it. Post 1.0 obviously as it is very near and hebrew would most likely require quite a few code changes.
ihsan
Posts: 30
Joined: March 1st, 2005, 4:26 pm
Location: Istanbul, TURKEY

Finally

Post by ihsan »

I've found the reason and also found a solution to this.
:D :D :D :D

coming soon.... with all your help.

:twisted:
Westnoth is ruled by anNOYing King of Dragons
Ayin
Inactive Developer
Posts: 294
Joined: March 30th, 2004, 4:45 pm
Location: Nîmes, France
Contact:

Post by Ayin »

torangan wrote:Ihsan: while I don't know about the specific Wesnoth/SDL code I can tell you that C++ doesn't allow unicode in ''. Those specify a char which is usually a 8 bit type.
C++ has no problem with Unicode. Depending on the encoding, using UTF-8-encoded strings in std::strings, or wider characters in std::wstrings, is a suitable solution to store unicode strings.

However, SDL has some problems with dead keys, preventing many layouts of keyboards to enter accented characters properly.

İhsan, did you find how to solve this? This is would be a very welcome fix.
lwa
Inactive Developer
Posts: 271
Joined: June 11th, 2005, 8:19 am
Location: Paris, France

Post by lwa »

Ş is the unicode character u+015E (LATIN CAPITAL LETTER S WITH CEDILLA) You could try to use it as a wide char in C90 with something like

Code: Select all

 foo = L'\x015E' ;
This has a chance to work (not tested) but depend of the library.

If you just type

Code: Select all

 foo = 'Ş' ; 
the result will be editor dependant, either the 0xDE byte of ISO-8859-9 (turkish character set) and it will not work in the game, either two UTF-8 bytes 0xC4 0x9E and may fail at compile time.
Ayin
Inactive Developer
Posts: 294
Joined: March 30th, 2004, 4:45 pm
Location: Nîmes, France
Contact:

Post by Ayin »

Iwa: the problem is in-game character input, not character coding. Coding internation characters has worked correctly for years.
lwa
Inactive Developer
Posts: 271
Joined: June 11th, 2005, 8:19 am
Location: Paris, France

Post by lwa »

I told just a way to type non ascii character within the c++ code. Theyre is probably not much.

Well, I've made some tests. When I type in the unit search box

Code: Select all

dead ` + a
Apparently I does not have the expected

Code: Select all

à
but a

Code: Select all

a
instead
But if it type the sequence very quickly I have the right character.
Apparently some timer need to be adjusted on dead key.

Notice also that the Copy/Paste does not work well (on Mac OS X at least) with non ascii characters.
When a copy/paste

Code: Select all

Ş
I got "^" and a square. copying/pasting

Code: Select all

à
give nothing.
ihsan
Posts: 30
Joined: March 1st, 2005, 4:26 pm
Location: Istanbul, TURKEY

Post by ihsan »

Ayin wrote: İhsan, did you find how to solve this? This is would be a very welcome fix.
Hi. Actually I put the patch to savannah, However this patch is easy for
Turkish characters, but when we consider the other languages
the programmers did not wanted to solve this in this way, because it
is a bug of sdl.

the link for the patch is here

http://savannah.nongnu.org/bugs/?func=d ... m_id=12169

it is self explained.

ihsan.
Westnoth is ruled by anNOYing King of Dragons
lwa
Inactive Developer
Posts: 271
Joined: June 11th, 2005, 8:19 am
Location: Paris, France

Post by lwa »

It's impossible to fix this within Wesnoth.
SDL X11 driver should use Xutf8LookupString (for XFree86 >= 4.0.2)
instead of XLookupString who is expected to output iso8859-1 characters only.
Post Reply