]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/stc/_stc_utf8_methods.py
2 def AddTextUTF8(self
, text
):
4 Add UTF8 encoded text to the document at the current position.
5 Works 'natively' in a unicode build of wxPython, and will also work
6 in an ansi build if the UTF8 text is compatible with the current
10 u
= text
.decode('utf-8')
11 text
= u
.encode(wx
.GetDefaultPyEncoding())
15 def InsertTextUTF8(self
, pos
, text
):
17 Insert UTF8 encoded text at a position. Works 'natively' in a
18 unicode build of wxPython, and will also work in an ansi build if
19 the UTF8 text is compatible with the current encoding.
21 if not wx
.USE_UNICODE
:
22 u
= text
.decode('utf-8')
23 text
= u
.encode(wx
.GetDefaultPyEncoding())
24 self
.InsertTextRaw(pos
, text
)
27 def GetCurLineUTF8(self
):
29 Retrieve the UTF8 text of the line containing the caret, and also
30 the index of the caret on the line. In an ansi build of wxPython
31 the text retrieved from the document is assumed to be in the
32 current default encoding.
34 text
, pos
= self
.GetCurLineRaw()
35 if not wx
.USE_UNICODE
:
36 u
= text
.decode(wx
.GetDefaultPyEncoding())
37 text
= u
.encode('utf-8')
41 def GetLineUTF8(self
, line
):
43 Retrieve the contents of a line as UTF8. In an ansi build of wxPython
44 the text retrieved from the document is assumed to be in the
45 current default encoding.
47 text
= self
.GetLineRaw(line
)
48 if not wx
.USE_UNICODE
:
49 u
= text
.decode(wx
.GetDefaultPyEncoding())
50 text
= u
.encode('utf-8')
54 def GetSelectedTextUTF8(self
):
56 Retrieve the selected text as UTF8. In an ansi build of wxPython
57 the text retrieved from the document is assumed to be in the
58 current default encoding.
60 text
= self
.GetSelectedTextRaw()
61 if not wx
.USE_UNICODE
:
62 u
= text
.decode(wx
.GetDefaultPyEncoding())
63 text
= u
.encode('utf-8')
67 def GetTextRangeUTF8(self
, startPos
, endPos
):
69 Retrieve a range of text as UTF8. In an ansi build of wxPython
70 the text retrieved from the document is assumed to be in the
71 current default encoding.
73 text
= self
.GetTextRangeRaw(startPos
, endPos
)
74 if not wx
.USE_UNICODE
:
75 u
= text
.decode(wx
.GetDefaultPyEncoding())
76 text
= u
.encode('utf-8')
80 def SetTextUTF8(self
, text
):
82 Replace the contents of the document with the UTF8 text given.
83 Works 'natively' in a unicode build of wxPython, and will also
84 work in an ansi build if the UTF8 text is compatible with the
87 if not wx
.USE_UNICODE
:
88 u
= text
.decode('utf-8')
89 text
= u
.encode(wx
.GetDefaultPyEncoding())
93 def GetTextUTF8(self
):
95 Retrieve all the text in the document as UTF8. In an ansi build
96 of wxPython the text retrieved from the document is assumed to be
97 in the current default encoding.
99 text
= self
.GetTextRaw()
100 if not wx
.USE_UNICODE
:
101 u
= text
.decode(wx
.GetDefaultPyEncoding())
102 text
= u
.encode('utf-8')
106 def AppendTextUTF8(self
, text
):
108 Append a UTF8 string to the end of the document without changing
109 the selection. Works 'natively' in a unicode build of wxPython,
110 and will also work in an ansi build if the UTF8 text is compatible
111 with the current encoding.
113 if not wx
.USE_UNICODE
:
114 u
= text
.decode('utf-8')
115 text
= u
.encode(wx
.GetDefaultPyEncoding())
116 self
.AppendTextRaw(text
)