Use utf-8 for saving to file. Patch #1730543

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46336 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2007-06-05 21:50:57 +00:00
parent 74ef4c65c8
commit 544c04c362

View File

@@ -25,13 +25,18 @@ class TextDocument(wx.lib.docview.Document):
def SaveObject(self, fileObject): def SaveObject(self, fileObject):
view = self.GetFirstView() view = self.GetFirstView()
fileObject.write(view.GetTextCtrl().GetValue()) val = view.GetTextCtrl().GetValue()
if wx.USE_UNICODE:
val = val.encode('utf-8')
fileObject.write(val)
return True return True
def LoadObject(self, fileObject): def LoadObject(self, fileObject):
view = self.GetFirstView() view = self.GetFirstView()
data = fileObject.read() data = fileObject.read()
if wx.USE_UNICODE:
data = data.decode('utf-8')
view.GetTextCtrl().SetValue(data) view.GetTextCtrl().SetValue(data)
return True return True
@@ -93,7 +98,7 @@ class TextView(wx.lib.docview.View):
wordWrapStyle = wx.TE_WORDWRAP wordWrapStyle = wx.TE_WORDWRAP
else: else:
wordWrapStyle = wx.TE_DONTWRAP wordWrapStyle = wx.TE_DONTWRAP
textCtrl = wx.TextCtrl(parent, -1, pos = wx.DefaultPosition, size = parent.GetClientSize(), style = wx.TE_MULTILINE | wordWrapStyle) textCtrl = wx.TextCtrl(parent, -1, pos = wx.DefaultPosition, size = parent.GetClientSize(), style = wx.TE_MULTILINE | wx.TE_RICH | wordWrapStyle)
textCtrl.SetFont(font) textCtrl.SetFont(font)
textCtrl.SetForegroundColour(color) textCtrl.SetForegroundColour(color)
textCtrl.SetValue(value) textCtrl.SetValue(value)
@@ -521,7 +526,7 @@ class TextOptionsPanel(wx.Panel):
nativeFont.FromString(self._textFont.GetNativeFontInfoDesc()) nativeFont.FromString(self._textFont.GetNativeFontInfoDesc())
font = wx.NullFont font = wx.NullFont
font.SetNativeFontInfo(nativeFont) font.SetNativeFontInfo(nativeFont)
font.SetPointSize(self._sampleTextCtrl.GetFont().GetPointSize()) # Use the standard point size #font.SetPointSize(self._sampleTextCtrl.GetFont().GetPointSize()) # Use the standard point size
self._sampleTextCtrl.SetFont(font) self._sampleTextCtrl.SetFont(font)
self._sampleTextCtrl.SetForegroundColour(self._textColor) self._sampleTextCtrl.SetForegroundColour(self._textColor)
self._sampleTextCtrl.SetValue(_("%d pt. %s") % (self._textFont.GetPointSize(), self._textFont.GetFaceName())) self._sampleTextCtrl.SetValue(_("%d pt. %s") % (self._textFont.GetPointSize(), self._textFont.GetFaceName()))