any secret to using unicode in StyledTextCtrl?

I'm not having any luck with unicode characters in a StyledTextCtrl.
I'm trying to insert bullets by inserting u"\u25AA". When I do, the
widget midbehaves (cursor movement isn't right, text disappears, etc).
The version of wxPython I'm using is "2.8.9.1 (gtk2-unicode)"

Hello,

I'm not having any luck with unicode characters in a StyledTextCtrl.
I'm trying to insert bullets by inserting u"\u25AA". When I do, the
widget midbehaves (cursor movement isn't right, text disappears, etc).
The version of wxPython I'm using is "2.8.9.1 (gtk2-unicode)"

How are you inserting the text into the buffer?

It works fine on my windows machine with b.AppendText(u"\u25AA").
(default encoding cp1292).

The STC is a wrapper around Scintilla, which stores its character
bytes internally as UTF-8 so depending upon your systems default
encoding you might be getting some issues with how the bytes are being
interpreted.

Cody

···

On Fri, Feb 26, 2010 at 4:19 PM, Bryan Oakley <bryan.oakley@gmail.com> wrote:

I'm doing it exactly as you show:

self.AppendText(u"\u25AA")

The characters usually appear, but other parts of the line gets
garbled. I guess it could have something to do with the font, but I'm
using the default font, default encoding on a relatively standard RHEL
system.

···

On Fri, Feb 26, 2010 at 4:39 PM, Cody Precord <codyprecord@gmail.com> wrote:

Hello,

On Fri, Feb 26, 2010 at 4:19 PM, Bryan Oakley <bryan.oakley@gmail.com> wrote:

I'm not having any luck with unicode characters in a StyledTextCtrl.
I'm trying to insert bullets by inserting u"\u25AA". When I do, the
widget midbehaves (cursor movement isn't right, text disappears, etc).
The version of wxPython I'm using is "2.8.9.1 (gtk2-unicode)"

How are you inserting the text into the buffer?

It works fine on my windows machine with b.AppendText(u"\u25AA").
(default encoding cp1292).

The STC is a wrapper around Scintilla, which stores its character
bytes internally as UTF-8 so depending upon your systems default
encoding you might be getting some issues with how the bytes are being
interpreted.

Cody

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

I've discovered my problem isn't in inserting, it's in adjusting the
selection. It only appeared to misbehave but my code was deleting more
characters on a replace than it should. It appears when I'm counting
characters to adjust the selection I'm off pretty much by one per
multibyte character.

Technically, you're off by the number of bytes exceeding one per multibyte
character. Depending on the language, the characer, and your encoding,
there could be more than 2 bytes in some multi-byte characters.

David

···

-----Original Message-----
From: wxpython-users@googlegroups.com
[mailto:wxpython-users@googlegroups.com] On Behalf Of Bryan Oakley
Sent: Saturday, February 27, 2010 9:26 AM
To: wxpython-users@googlegroups.com
Subject: Re: [wxPython-users] any secret to using unicode in
StyledTextCtrl?

I've discovered my problem isn't in inserting, it's in
adjusting the selection. It only appeared to misbehave but my
code was deleting more characters on a replace than it
should. It appears when I'm counting characters to adjust
the selection I'm off pretty much by one per multibyte character.

--
To unsubscribe, send email to
wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

You are correct. I had made the false assumption that, given a
position, the next character is at position+1. Unfortunately (and
strangely, IMO) that is not the case. Once I discovered
PositionAfter() and PositionBefore() I was able to fix my code.

···

On Mon, Mar 1, 2010 at 9:51 AM, David <transana@gmail.com> wrote:

Technically, you're off by the number of bytes exceeding one per multibyte
character. Depending on the language, the characer, and your encoding,
there could be more than 2 bytes in some multi-byte characters.