loading_text=cegui.WindowManager.getSingleton().getWindow("loading_text");
loading_text.text=u'Učitavam mapu'
the second non-ascii character doesn't get displayed correctly:
http://img91.imageshack.us/img91/3076/snapshot3dw9.jpg
the .py file is saved as UTF8
s = u'U\u010ditavam mapu' #\u010d - č
loading_text.text=s
s='\xc4\x8dikara'
the font I use has the charachers I need, and the C++ version of my
program uses the same resources and unicode chars get displayed
correctly.
Does CEGUI support the use of unicode strings in C++?
LakinOn 5/21/07, Krešimir Špes < kresim...@gmail.com > wrote:
so, any clues? anyone? this is really important for my project :/
Unfortunetly I won't be able to test for a day or two
Andy
1) I've set a unicode string with special chars in the layout file:
'čikara' and it was displayed correctly and output of
loading_text.text.c_str() returned u"čikara"
2) when set u"čušo" in code, I get u"Ã\x84Â\x8duÃ…Â\xa1o" from the
c_str() ?
3) when I set a unicode utf8 string ('\xc4\x8dikara') I get: u"Ä
\x8dikara"
I've yet to try this on windows though.
I will try to find some time to understand what is going on.
And this will fix the bug? If so we can add next code to CEGUI __init__.py file
def String( s ):
if isinstance( s, str ):
return _cegui_.String( s )
elif isinstance( s, unicode ):
return _cegui_.String( cstr=s )
else:
raise some exception
What do you think?
Init_Load=cegui.String(num=1,code_point=0x010d)
Init_Load.append('ikara')
there's really not that much to unicode as one might think, it is
basicly an universal code page that contain EVERY single character in
existance. Thusly, a single character has to have 32 bits.
there are many unicode transformation formats, most comonly used would
be utf8 which is an ascii extension that works in a way that all codes
lower then 128 are treated as ascii and all larger are unicode chars
that span two or more bytes.
cegui in c++ comonly uses utf8 for cegui.String assignment which is
why I'm puzzeled as to why '\xc4\x8d' results in cegui transforming
this into something different :? So, we should concentrate on making
cegui understand python utf8 strings to solve the problem.
also, cegui can take int32* which coresponds I believe to python's
unicode strings, but they get transformed wierdly as well
Can someone please tell me how to debug this? I would gladly do it,
but I don't know how :/ By default, cegui takes utf32 unsigned char*
strings however it seems to be having a problem with converting python
strings to unsigned char
1) 0x010d is a unicode codepoint of 'č' (c with an inverted ^ above
it)
2) '\xc4\x8d' is a utf8 transformation of that character into a
standard 8-bit string.
3) s=cegui.String('\xc4\x8d') results into two diferent characters:
196 & 141 (C4 & 8D)
s[0] returns 196, s[1] returns 141 and s[2] returns 0. however, s[0]
should've been 296 (010D) and s[1] : 0
so, my educated guess is that in String.__init__ each ascii charcter
is taken and inserted seperately into the string which is okay with
ascii chars but not with utf8 chars which have to be first converted
into unicode codepoints before insertion.
can you post cegui.String constructor code please?
On May 27, 3:08 pm, "Andy Miller" <nzmill...@gmail.com> wrote:
> Can you send me some UTF8 strings (with descriptions etc of what they are
> meant to show) as there seem to be multiple implementations and it's
> something I'm "learning"...
>
> It should be reasonably simple to fix once I understand it better
>
> Cheers
>
> Andy
>
if you need any more info on unicode and utf-X, don't hesitate to
ask :)