mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Add writeWString for std::string
This commit is contained in:
@@ -380,6 +380,7 @@ void String::toUnicode(wchar_t *dest)
|
||||
{
|
||||
for (int i=0; i<length(); i++)
|
||||
dest[i]=(wchar_t)CString[i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+23
-2
@@ -194,18 +194,39 @@ void ChunkFile::writeWString(String str) {
|
||||
wchar_t *text;
|
||||
int len=str.length();
|
||||
#ifdef UNICODE
|
||||
#error
|
||||
text = str.getPointer();
|
||||
#else
|
||||
text=new wchar_t[len+1];
|
||||
text = new wchar_t[len+1];
|
||||
str.toUnicode(text);
|
||||
#endif
|
||||
writeInt(len);
|
||||
writeData((char *)text,len*sizeof(wchar_t));
|
||||
writeData((char *)text, len * sizeof(wchar_t));
|
||||
#ifndef UNICODE
|
||||
delete [] text;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChunkFile::writeWString(const std::string &str) {
|
||||
unsigned short *text;
|
||||
int len=str.length();
|
||||
#ifdef UNICODE
|
||||
#error
|
||||
text = str.c_str();
|
||||
#else
|
||||
text = new unsigned short[len+1];
|
||||
for (int i=0; i<len; i++)
|
||||
text[i]=str[i];
|
||||
text[len]=0;
|
||||
#endif
|
||||
writeInt(len);
|
||||
writeData((char *)text, len * sizeof(unsigned short));
|
||||
#ifndef UNICODE
|
||||
delete [] text;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
String ChunkFile::readWString() {
|
||||
int len=readInt();
|
||||
wchar_t *text = new wchar_t[len+1];
|
||||
|
||||
+2
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
// EITHER a chunk contains ONLY data
|
||||
// OR it contains ONLY other chunks
|
||||
// otherwise the scheme breakes.
|
||||
// otherwise the scheme breaks.
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
|
||||
void writeInt(int i);
|
||||
void writeWString(String str);
|
||||
void writeWString(const std::string &str);
|
||||
void writeData(const void *data, int count);
|
||||
|
||||
int getCurrentChunkSize();
|
||||
|
||||
Reference in New Issue
Block a user