Fix several bugs in multibyteToWString. This also fixes pasting.
Add clear function to strings. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5332 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
d4204168c6
commit
d3ac819504
|
@ -1,6 +1,7 @@
|
|||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
|
||||
- add clear function to strings.
|
||||
- Collision manager now using const camera pointers.
|
||||
- Several fixes for SceneNodeAnimatorCollisionResponse, based on http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=33098&p=290746
|
||||
Thanks to all people who reported and to JLouisB and kinkreet for the patches:
|
||||
|
|
|
@ -510,6 +510,16 @@ public:
|
|||
return (size() == 0);
|
||||
}
|
||||
|
||||
void clear(bool releaseMemory=true)
|
||||
{
|
||||
if ( releaseMemory )
|
||||
{
|
||||
reallocate(1);
|
||||
}
|
||||
array[0] = 0;
|
||||
used = 1;
|
||||
}
|
||||
|
||||
//! Returns character string
|
||||
/** \return pointer to C-style NUL terminated string. */
|
||||
const T* c_str() const
|
||||
|
@ -1387,7 +1397,7 @@ typedef string<wchar_t> stringw;
|
|||
What the function does exactly depends on the LC_CTYPE of the current c locale.
|
||||
\param destination Wide-character string receiving the converted source
|
||||
\param source multibyte string
|
||||
\return The number of wide characters written to destination, not including the eventual terminating null character. */
|
||||
\return The number of wide characters written to destination, not including the eventual terminating null character or -1 when conversion failed */
|
||||
static inline size_t multibyteToWString(string<wchar_t>& destination, const core::string<c8>& source)
|
||||
{
|
||||
return multibyteToWString(destination, source.c_str(), (u32)source.size());
|
||||
|
@ -1398,7 +1408,7 @@ static inline size_t multibyteToWString(string<wchar_t>& destination, const core
|
|||
What the function does exactly depends on the LC_CTYPE of the current c locale.
|
||||
\param destination Wide-character string receiving the converted source
|
||||
\param source multibyte string
|
||||
\return The number of wide characters written to destination, not including the eventual terminating null character. */
|
||||
\return The number of wide characters written to destination, not including the eventual terminating null character or -1 when conversion failed. */
|
||||
static inline size_t multibyteToWString(string<wchar_t>& destination, const char* source)
|
||||
{
|
||||
u32 s = source ? (u32)strlen(source) : 0;
|
||||
|
@ -1419,13 +1429,22 @@ static size_t multibyteToWString(string<wchar_t>& destination, const char* sourc
|
|||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
destination.used = (u32)written;
|
||||
destination.array[destination.used] = 0;
|
||||
if ( written != (size_t)-1 )
|
||||
{
|
||||
destination.used = (u32)written+1;
|
||||
destination.array[destination.used-1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Likely character which got converted until the invalid character was encountered are in destination now.
|
||||
// And it seems even 0-terminated, but I found no documentation anywhere that this (the 0-termination) is guaranteed :-(
|
||||
destination.clear();
|
||||
}
|
||||
return written;
|
||||
}
|
||||
else
|
||||
{
|
||||
destination.empty();
|
||||
destination.clear();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue