Commit Graph

44 Commits

Author SHA1 Message Date
Vadim Zeitlin
4502e7563b Fix wxTextInputStream for input starting with BOM-like bytes
Contrary to what a comment in wxTextInputStream::GetChar() said, it is
actually possible to get more than one wide character from a call to
wxMBConv::ToWChar(len+1) even if a previous call to ToWChar(len) failed
to decode anything at all. This happens with wxConvAuto because it keeps
returning an error while it doesn't have enough data to determine if the
input contains a BOM or not, but then returns all the characters
examined so far at once if it turns out that there was no BOM, after
all.

The simplest case in which this created problems was just input starting
with a NUL byte as it as this could be a start of UTF-32BE BOM.

The fix consists in keeping all the bytes read but not yet decoded in
the m_lastBytes buffer and retrying to decode them during the next
GetChar() call. This implies keeping track of how much valid data is
there in m_lastBytes exactly, as we can't discard the already decoded
data immediately, but need to keep it in the buffer too, in order to
allow implementing UngetLast(). Incidentally, UngetLast() was totally
broken for UTF-16/32 input (containing NUL bytes in the middle of the
characters) before and this change fixes this as a side effect.

Also add test cases for previously failing inputs.
2017-11-09 23:49:59 +01:00
Vadim Zeitlin
f365b0712b Get rid of wxTextInputStream code dealing with wxEOT
Having NextChar() returning wxEOT only for GetChar() to turn it back to
NUL didn't make any sense, just return NUL directly and get rid of
GetChar/NextChar() distinction.

No real changes, just simplify the code.
2017-11-08 23:27:13 +01:00
Lauri Nurmi
4281cb4daa Use enums, not typedef enums, in all public headers. 2016-02-07 01:11:25 +02:00
Vadim Zeitlin
823a2337f6 Make wxTextStream classes work with surrogates under MSW
On the platforms using UTF-16 for wchar_t we can't read nor write Unicode data
one wchar_t at a time as a single half of a surrogate character can't be
converted to or from the encoding of the stream.

To fix this, we may need to store the last wchar_t already read from the
stream but not returned yet in wxTextInputStream::NextChar() and store,
without writing it, the wchar_t passed to wxTextOutputStream::PutChar() until
the second half of the surrogate is written.

See #17070.
2015-11-13 19:36:33 +01:00
Catalin
a2ebc9daf6 Add wxTextOutputStream::Write<>().
The new method allows to write into wxTextOutputStream anything that can be
streamed into wxString and allows to simplify the existing code.
2015-06-23 18:20:19 +02:00
Vadim Zeitlin
8c4b1dcbd0 Add wxInt64 support to wxText{Input,Output}Stream.
Add explicit Read64[S]() and Write64() methods.

Closes #14685.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76171 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-03-19 22:57:44 +00:00
Paul Cornett
967a94c91a remove WXWIN_COMPATIBILITY_2_6, add WXWIN_COMPATIBILITY_3_0
closes #15792

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-01-04 20:07:33 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
23a9142e27 Add wxText{Input,Output}Stream::Get{Input,Output}Stream() methods.
These methods simply return the underlying low-level stream.

See #10807.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67286 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-03-22 17:15:45 +00:00
Vadim Zeitlin
c0c133e13b add wx-prefixed and semicolon-requiring versions of DECLARE_NO_{COPY,ASSIGN}_CLASS macros
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58757 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-02-08 11:45:59 +00:00
Vadim Zeitlin
ca8cf4fffb added wxTextOutputStream::Flush(): this is necessary with the stateful encodings, such as UTF-7
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53890 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-06-01 03:09:25 +00:00
Václav Slavík
b5dbe15d0b added WXDLLIMPEXP_FWD_FOO macros in addition to WXDLLIMPEXP_FOO for use with forward declarations (in preparation for GCC visibility support)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47254 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-07-09 10:09:52 +00:00
Václav Slavík
d3e9a6f3bf have only one string form of operator<< in output streams
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46613 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-06-22 11:12:21 +00:00
Włodzimierz Skiba
40ff126ac4 Deprecated and obsolete parts marked up for backward compatibility.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38717 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2006-04-14 17:01:16 +00:00
Vadim Zeitlin
d36c9347ea added wxMBConv::Clone() to be able to copy conversion objects polymorphically
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38576 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2006-04-05 16:10:08 +00:00
Vadim Zeitlin
830f8f11bc 1. changed all "wxMBConv& conv" parameters to "const wxMBConv&"
2. this allows to use wxConvAuto() instead of wxConvUTF8 as default value
   for this parameter in the classes which read text from the file: wxConvAuto
   automatically recognizes the BOM at the start of file and uses the correct
   conversion
3. don't use Windows for UTF-7 conversions as there is no way to make it
   fail on invalid UTF-7 strings; use our own wxMBConvUtf7 instead


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38570 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2006-04-05 14:37:47 +00:00
Mart Raudsepp
8907154c1a Nuke #pragma implementation/interface's
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35650 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2005-09-23 12:56:45 +00:00
Ryan Norton
ba8546912d wxTextOutputStream::PutChar and text stream test
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-11-21 18:26:38 +00:00
Vadim Zeitlin
fdd99f154a added wxTextInputStream::operator>>(wchar_t) for compilers which support this
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30047 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-10-20 22:50:03 +00:00
Włodzimierz Skiba
254a21292b Warning fixes found under hardest mode of OpenWatcom. Seems clean in Borland, MinGW and DMC.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29660 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-10-05 15:38:40 +00:00
Włodzimierz Skiba
cb719f2e29 Source cleaning: whitespaces, tabs, -1/wxID_ANY/wxNOT_FOUND/wxDefaultCoord, TRUE/true, FALSE/false, !!/!IsEmpty().
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29285 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-09-23 18:20:56 +00:00
Vadim Zeitlin
e4940febd0 only define operator<<(wchar_t) in Unicode build
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29114 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-09-12 15:08:36 +00:00
Vadim Zeitlin
3ca1bf5add overload operator<<() for wchar_t too (if applicable/possible); this fixes the problem with << '\n' producing '10' on output
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29094 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-09-11 18:42:58 +00:00
Julian Smart
655719367a Use old licence name
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27408 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-05-23 20:53:33 +00:00
Julian Smart
77ffb5937e Name and version changes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27404 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-05-23 14:56:36 +00:00
Vadim Zeitlin
bcda793a4e added wxTextInputStream::ReadChar() (part of patch 792932)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23946 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-09-26 20:15:38 +00:00
Václav Slavík
1202890513 added support for gcc precompiled headers
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22722 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-08-09 12:38:21 +00:00
Vadim Zeitlin
fc7a2a602b undisable many warnings for VC++ in defs.h and fixed several thousands of them in the sources
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22222 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-07-22 00:24:07 +00:00
Vadim Zeitlin
2348a84293 made wxTextInputStream Unicode safe and general cleanup (patch 653775)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21825 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-07-09 22:55:57 +00:00
Vadim Zeitlin
bddd7a8d89 renamed WXDLLEXPORT_BASE/CORE to WXDLLIMPEXP_BASE/CORE
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21570 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-07-02 01:59:24 +00:00
Vadim Zeitlin
886dd7d28e fixes needed for separate DLL build to work
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21569 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-07-02 01:41:23 +00:00
Julian Smart
371a5b4e62 Removed erroneous copyright names and corrected licence spelling
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-03-17 10:34:04 +00:00
Vadim Zeitlin
2b5f62a0b2 merged 2.4 branch into the trunk
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18040 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-12-04 14:11:26 +00:00
Gilles Depeyrot
af49c4b8a2 disable use of #pragma interface under Mac OS X
GNU compiler included with Mac OS X 10.2 (Jaguar) as well as August Developer
Tools update contain a bug concerning #pragma interface handling that can only
be worked around by not using them (and they are not necessary anyways)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16884 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-08-31 11:29:13 +00:00
Bryan Petty
f6bcfd974e merged 2.2 branch
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2000-07-15 19:51:35 +00:00
David Webster
28f5bdb49b Eliminate comma's after last element in an enum
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5065 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-12-22 18:40:24 +00:00
Robert Roebling
c7a9fa36e4 Minor changes to wxTreeCtrl's horiz size,
Text stream now can write Mac/Unix/Dos EOL on resp. other platforms,
  Fixed return value of wxBufferedOutputStream::GetSize() and ::TellO()


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5036 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-12-20 16:15:32 +00:00
Sylvain Bougnoux
191549ed17 Accept list of separators as a wxString instead of wxChar\nTurn NextNonWhiteSpace to NextNonSeparators\nIntroduce EatEOL (major factorization)\nFix GetC() call on last char introduce a bug
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4252 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-10-29 11:18:46 +00:00
Sylvain Bougnoux
9853d97739 operator >> wxString eat word by default. \n Add wxTextInputStream::Get/SetStringSeparator.\n Add wxTextInputStream::wxTextInputStream(wxInputStream, const wxChar &sep=' ')
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4241 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-10-28 12:33:55 +00:00
Robert Roebling
65045edde4 Added wxFFileStream base on wxFFile (as opposed to wxFile)
Implemented the "endl" thing for text streams,
  Corrected cursor display for text ctrls,
  Corrected the strange spin button behaviour when dynamically
    changing its range
  Corrcected bug in wxListBox when programmatically unselecting
   an item in multi-select mode (bug reports are getting esoteric)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3440 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-08-22 16:12:48 +00:00
Robert Roebling
ed58dbeab6 Changed a few #include <xxx.h> to #include "xxx.h"
Added endl operator to wxTextStream
  Corrrected a few misbehaviours in wxFileDialog,
  Corrected tab traversal a bit
  Corrected wxImage::SetData() to not copy, but take
    the data and care for ref couting as well


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-08-20 22:52:21 +00:00
Robert Roebling
cd25b18c8e Renamed wxStream::StreamSize() to wxStream::GetSize()
Add wxStream bool operator !().
  Made wxTextStream safe for conversion from/to Mac/DOS/Unix
  Added wxFrame::Iconize()
  Applied patch for stippled brushes.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-07-24 10:50:13 +00:00
Guilhem Lavaux
940ddb190c * Changed char to wxChar in operators.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2991 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-07-13 06:27:42 +00:00
Guilhem Lavaux
fae05df5a9 * New wxStreams (to be documented), new classes: wxBufferedStreams,
wxTextStreams


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2962 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-07-07 17:45:35 +00:00