Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
7b8b5a12
Commit
7b8b5a12
authored
Dec 07, 2010
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compatibility with wxWdigets 2.9+: there is now a built in wxString::FromUTF8 function, use it
parent
733a64aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
src/util/io/reader.cpp
src/util/io/reader.cpp
+18
-11
No files found.
src/util/io/reader.cpp
View file @
7b8b5a12
...
...
@@ -138,10 +138,10 @@ void Reader::moveNext() {
*/
template
<
typename
T
>
class
LocalVector
{
public:
LocalVector
()
:
size
(
0
),
alloced
(
SMALL_SIZE
),
buffer
(
small
)
{}
LocalVector
()
:
the_
size
(
0
),
alloced
(
SMALL_SIZE
),
buffer
(
small
)
{}
~
LocalVector
()
{
if
(
buffer
!=
small
)
free
(
buffer
);
}
void
push_back
(
T
t
)
{
if
(
size
>=
alloced
)
{
if
(
the_
size
>=
alloced
)
{
// double buffer size
if
(
buffer
!=
small
)
{
buffer
=
(
T
*
)
realloc
(
buffer
,
sizeof
(
T
)
*
alloced
*
2
);
...
...
@@ -151,12 +151,13 @@ template <typename T> class LocalVector {
}
alloced
*=
2
;
}
buffer
[
size
++
]
=
t
;
buffer
[
the_
size
++
]
=
t
;
}
const
T
*
get
()
{
return
buffer
;
}
inline
const
T
*
get
()
const
{
return
buffer
;
}
inline
size_t
size
()
const
{
return
the_size
;
}
private:
static
const
int
SMALL_SIZE
=
1024
;
size_t
size
,
alloced
;
size_t
the_
size
,
alloced
;
T
*
buffer
;
T
small
[
SMALL_SIZE
];
};
...
...
@@ -190,14 +191,20 @@ String read_utf8_line(wxInputStream& input, bool eat_bom, bool until_eof) {
}
else
if
(
size
==
0
)
{
return
_
(
""
);
}
String
result
;
#ifdef UNICODE
// NOTE: wx doc is wrong, parameter to GetWritableChar is numer of characters, not bytes
Char
*
result_buf
=
result
.
GetWriteBuf
(
size
+
1
);
wxConvUTF8
.
MB2WC
(
result_buf
,
buffer
.
get
(),
size
+
1
);
result
.
UngetWriteBuf
(
size
);
return
eat_bom
?
decodeUTF8BOM
(
result
)
:
result
;
#if wxVERSION_NUMBER >= 2900
String
result
=
wxString
::
FromUTF8
(
buffer
.
get
(),
buffer
.
size
());
return
eat_bom
?
decodeUTF8BOM
(
result
)
:
result
;
#else
// NOTE: wx doc is wrong, parameter to GetWritableChar is numer of characters, not bytes
String
result
;
Char
*
result_buf
=
result
.
GetWriteBuf
(
size
+
1
);
wxConvUTF8
.
MB2WC
(
result_buf
,
buffer
.
get
(),
size
+
1
);
result
.
UngetWriteBuf
(
size
);
return
eat_bom
?
decodeUTF8BOM
(
result
)
:
result
;
#endif
#else
String
result
;
// first to wchar, then back to local
vector
<
wchar_t
>
buf2
;
buf2
.
resize
(
size
+
1
);
wxConvUTF8
.
MB2WC
(
&
buf2
[
0
],
buffer
.
get
(),
size
+
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment