apply a style to unicode string

Hi all.I attach a script in which I try to apply a style to a unicode string with value u’èèèèè ’

In particular, in my code I put these 2 line:

 ed.StartStyling (0, stc.STC_INDICS_MASK)

 ed.SetStyling (len (demoText) stc.STC_INDIC0_MASK)

with demoText = u’èèèèè’ but this does not work properly.

Is there a way to determine exactly how many bytes of the string so as toapply exactly the style with the correct length?

Attached script.

StyledTextCtrl_1.py (8.32 KB)

···


Fabio Spadaro
www.fabiospadaro.com

Hi,

···

On Thu, Mar 31, 2011 at 3:52 PM, Fabio Spadaro <fabiolinospad@gmail.com> wrote:

Hi all.I attach a script in which I try to apply a style to a unicode
string with value u'èèèèè '
In particular, in my code I put these 2 line:
ed.StartStyling (0, stc.STC_INDICS_MASK)
ed.SetStyling (len (demoText) stc.STC_INDIC0_MASK)
with demoText = u'èèèèè' but this does not work properly.
Is there a way to determine exactly how many bytes of the string so
as toapply exactly the style with the correct length?

You need to convert the unicode string to UTF-8 to properly measure
the length. The StyledTextCtrl (Scintilla) uses utf-8 internally.

Cody

Yes and do not forget the start position.

jmf

···

On 31 mar, 22:57, Cody Precord <codyprec...@gmail.com> wrote:

Hi,

On Thu, Mar 31, 2011 at 3:52 PM, Fabio Spadaro <fabiolinos...@gmail.com> wrote:
> Hi all.I attach a script in which I try to apply a style to a unicode

You need to convert the unicode string to UTF-8 to properly measure
the length. The StyledTextCtrl (Scintilla) uses utf-8 internally.

Hi

···

2011/4/1 jmfauth wxjmfauth@gmail.com

On 31 mar, 22:57, Cody Precord codyprec...@gmail.com wrote:

Hi,

On Thu, Mar 31, 2011 at 3:52 PM, Fabio Spadaro fabiolinos...@gmail.com wrote:

Hi all.I attach a script in which I try to apply a style to a unicode

You need to convert the unicode string to UTF-8 to properly measure
the length. The StyledTextCtrl (Scintilla) uses utf-8 internally.

Yes and do not forget the start position.

jmf


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

Work. Thanks a lot.


Fabio Spadaro
www.fabiospadaro.com